android: How to change ListPreference title colour?
Asked Answered
B

2

8

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.

ListPreference

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.

Bax answered 23/10, 2013 at 2:29 Comment(0)
T
8

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>

Tensive answered 23/5, 2016 at 12:37 Comment(2)
Nice, way cleaner solution!Bax
I'm always at a complete lost when it comes to messing around with styles.xml, after hours of digging through answers this is the one that lead me on the right path.Goodspeed
B
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.

Bax answered 24/10, 2013 at 3:10 Comment(4)
Did you get it? I want to change the background colorVorlage
@BhargavKumarR Unfortunately I didn't figure out a way without creating a custom widget following the linked answer.Bax
Thanks for reply. I spent enough time to do it with some kind of style attributes but could not. I will try your solution and +1 :)Vorlage
Bhargav Kumar R, maybe this? item name="android:windowBackground">@color/somecolor</item>Chong

© 2022 - 2024 — McMap. All rights reserved.