【问题标题】:android: How to change ListPreference title colour?android:如何更改 ListPreference 标题颜色?
【发布时间】:2013-10-23 02:29:09
【问题描述】:

我想将我的 ListPreference 的标题和线条颜色从蓝色更改为粉红色,以匹配我的操作栏的线条。

有什么想法吗?提前致谢!

我一直在通过 Android 的 themes.xmlstyles.xml 寻找类似 @​​987654324@ 的东西,但还没有弄清楚。

【问题讨论】:

    标签: android styles android-preferences


    【解决方案1】:

    今天遇到了同样的问题。 旧线程,但我找到了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>
    

    【讨论】:

    • 不错,更清洁的解决方案!
    • 在与styles.xml 混在一起时,我总是完全迷失方向,经过数小时的挖掘答案,这是引导我走上正确道路的答案。
    【解决方案2】:

    this answer 之后创建了一个自定义ListPreference 小部件。

    我希望能够简单地更改样式而不必实现自定义小部件,但我还没有想通。

    【讨论】:

    • 你明白了吗?我想改变背景颜色
    • @BhargavKumarR 不幸的是,如果不按照链接的答案创建自定义小部件,我想不出办法。
    • 感谢您的回复。我花了足够的时间使用某种样式属性来做到这一点,但做不到。我会尝试您的解决方案并 +1 :)
    • Bhargav Kumar R,也许是这个?项目名称="android:windowBackground">​​@color/somecolor
    猜你喜欢
    • 2019-08-25
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    • 2022-10-03
    相关资源
    最近更新 更多