修改PreferenceCategory摘要字段颜色。

huangapple 未分类评论44阅读模式
英文:

change PreferenceCategory summary field color

问题

如何更改PreferenceCategory摘要字段的颜色

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools">

  <PreferenceCategory
    android:paddingStart="0dp"
    app:allowDividerAbove="false"
    app:summary="Hello"
    app:title="@string/sync_header">

    <SwitchPreferenceCompat
        app:key="sync"
        app:title="@string/sync_title" />

    <SwitchPreferenceCompat
        app:dependency="sync"
        app:key="attachment"
        app:summaryOff="@string/attachment_summary_off"       <---------------
        app:summaryOn="@string/attachment_summary_on"         <---------------

        app:title="@string/attachment_title" />

    </PreferenceCategory>
</PreferenceScreen>

我的应用程序中默认的文本次要颜色是白色,应用程序背景默认为白色

<item name="android:textColorSecondary">@android:color/white</item>

因此,app:summaryOff="将在午夜同步" 总是白色并且变得不可见。

只需将摘要颜色从 white 更改为 gray

<item name="android:textColorSecondary">@android:color/darker_gray</item>

解决了摘要的目的,但会产生另一个颜色问题,因为应用程序的 textColorSecondary 必须为白色。

英文:

How to change the PreferenceCategory summary field color

&lt;PreferenceScreen xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
   xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
   xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;

  &lt;PreferenceCategory
    android:paddingStart=&quot;0dp&quot;
    app:allowDividerAbove=&quot;false&quot;
    app:summary=&quot;Hello&quot;
    app:title=&quot;@string/sync_header&quot;&gt;

    &lt;SwitchPreferenceCompat
        app:key=&quot;sync&quot;
        app:title=&quot;@string/sync_title&quot; /&gt;

    &lt;SwitchPreferenceCompat

        app:dependency=&quot;sync&quot;
        app:key=&quot;attachment&quot;
        app:summaryOff=&quot;@string/attachment_summary_off&quot;       &lt;---------------
        app:summaryOn=&quot;@string/attachment_summary_on&quot;         &lt;---------------

        app:title=&quot;@string/attachment_title&quot; /&gt;

    &lt;/PreferenceCategory&gt;
&lt;/PreferenceScreen&gt;

my default text-secondary color is white for the entire application, and application background is defaults to white

&lt;item name=&quot;android:textColorSecondary&quot;&gt;@android:color/white&lt;/item&gt;

So the app:summaryOff=&quot;Will Sync on Midnight&quot; is always white and becomes invisible.

Just want to change the summary color from white to gray.

&lt;item name=&quot;android:textColorSecondary&quot;&gt;@android:color/darker_gray&lt;/item&gt;

solves the purpose of summary but creates another color problem because textColorSecondary must be white for the app.

huangapple
  • 本文由 发表于 2020年7月24日 18:50:04
  • 转载请务必保留本文链接:https://java.coder-hub.com/63072081.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定