[英]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. 我想将我的Android应用偏好屏幕的外观更改为白色背景和深色文本。 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. 尝试打开首选项时,应用程序崩溃( AndroidRuntimeException: requestFeature() must be called before adding content
。
使用Theme.Light.NoTitleBar :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.