android: How to change ListPreference title colour?

泄露秘密 提交于 2019-11-29 19:45:38

问题


I would like to change the title and line color of my ListPreference from blue to pink, to match the line of my action bar.

Any ideas? Thanks in advance!

I've been looking through Android's themes.xml and styles.xml looking at things like dialogPreferenceStyle, but haven't figured it out yet.


回答1:


Had the same problem today. Old thread, but I found this: and it works perfectly.

Simply modify your styles.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <!-- Add this -->

    <item name="android:dialogTheme">@style/DialogStyle</item>
    <item name="android:alertDialogTheme">@style/DialogStyle</item>

</style>

<!-- Customize your color here -->

<style name="DialogStyle" parent="android:Theme.Material.Dialog">
    <item name="android:colorAccent">@color/colorAccent</item>
</style>




回答2:


Ended up creating a custom ListPreference widget, following this answer.

I hoped to be able to simply change the style without having to implement a custom widget, but I haven't figured that out yet.



来源:https://stackoverflow.com/questions/19531707/android-how-to-change-listpreference-title-colour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!