2013-10-23 171 views
6

我想將ListPreference的標題和線條顏色從藍色更改爲粉色,以匹配我的操作欄的行。android:如何更改ListPreference標題顏色?

ListPreference

任何想法?提前致謝!

我一直在尋找Android的themes.xmlstyles.xml看着像dialogPreferenceStyle這樣的東西,但還沒弄明白。

回答

5

今天有同樣的問題。 舊的線程,但我發現this:,它完美的作品。

只需修改您的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> 

+0

不錯,方式更乾淨的解決方案! – Felix

2

結束創建自定義ListPreference小部件,請按照this answer

我希望能夠簡單地改變風格而不必實現自定義小部件,但我還沒有想到。

+0

你收到了嗎?我想改變背景顏色 –

+0

@BhargavKumarR不幸的是,我沒有找到一種方法,沒有創建一個自定義的小工具,下面的鏈接的答案。 – Felix

+1

感謝您的回覆。我花了足夠的時間用某種風格屬性來完成它,但不能。我會嘗試你的解決方案和+1 :) –

相關問題