简体   繁体   English

如何更改Android首选项的文本颜色?

[英]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.

相关问题 Android XML-首选项-更改颜色 - Android xml - preferences - change color 如何在首选项 FRAGMENT 中更改首选项的文本颜色? - How do I change the text color of preferences in preference FRAGMENT? 如何在Android中更改CheckBoxPreference标题的文本颜色? - How to change Text Color of CheckBoxPreference's Title in android? 如何将React Native Android的默认文本颜色更改为黑色? - How to change React Native Android's default text color to black? Android RecyclerView 如何更改第一个项目的文本颜色 - Android RecyclerView how to change first item it's text color 如何使用正则表达式更改特定文本的颜色,Android 中的 SpannableString - How to change Specfic text's color using Regex, SpannableString in Android 如何在按下时更改 android AppCompatButton 的文本颜色 - How to change android AppCompatButton's text color on pressed 有没有一种方法可以在 Android 首选项中更改字体样式、颜色? - Is there a method to change font style,color in Android Preferences? Android Studio,共享首选项设置文本颜色 - Android Studio, Shared Preferences Set Text Color Android更改tabview的文本颜色而不是backgroundcolor - Android change tabview's text color not backgroundcolor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM