Question

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.

Was it helpful?

Solution

Use Theme.Light.NoTitleBar :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top