user519908
user519908

Reputation:

How to change text color of Android's preferences?

I want to change the look of my Android app's preference screen to white background and dark text color. It seems that I can change background color in the code. Is there a similar way to change text color of preferences in the code?

getListView().setBackgroundColor(Color.TRANSPARENT);
getListView().setCacheColorHint(Color.TRANSPARENT);
getListView().setBackgroundColor(Color.rgb(255, 255, 255));

The other way could be setting the activity's theme to light in the app's manifest:

android:theme="@android:style/Theme.Light"

However, this overrides the application's style, which currently is set to

android:theme="@android:style/Theme.NoTitleBar"

Thus, title bar is displayed in the preferences screen. I can try to remove the bar by

requestWindowFeature(Window.FEATURE_NO_TITLE);

The app then crashes (AndroidRuntimeException: requestFeature() must be called before adding content) when trying to open preferences.

Upvotes: 0

Views: 2512

Answers (1)

Dahlgren
Dahlgren

Reputation: 781

Use Theme.Light.NoTitleBar :)

Upvotes: 5

Related Questions