android - 增加 CheckboxPreference 标题和摘要文本大小以及首选项条目的发光

标签 android android-preferences listpreference checkboxpreference

您好,我正在优先处理消息设置。

我正在尝试更改 CheckboxPreference 的 android:title 和 android:summary 文本字体大小。

enter image description here

为此我正在尝试下面的代码

   <PreferenceCategory
    android:key="prefcategory1"
    android:title="GENERAL SETTINGS..." >

    <CheckBoxPreference
        android:defaultValue="false"
        android:enabled="true"
        android:key="checkBoxdelete"
        android:layout="@layout/mylayout"     <!--linking it to mylayout.xml -->
        android:summary="Deletes old messages as limits are reached"
        android:title="Delete old messages" />
  </PreferenceCategory>

mylayout.xml

<TextView android:id="@+android:id/title"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:paddingLeft="8dp"
    android:textColor="#FFFFFF"
    android:textSize="30px"
    android:textStyle="bold"/>  

<TextView android:id="@+android:id/summary"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:paddingLeft="8dp"
    android:textColor="#FFFFFF"
    android:textSize="20px"
    android:textStyle="bold"/>

通过使用它,文本大小会增加,如下面的屏幕截图所示。但是,我看不到复选框。我该如何解决这个问题?

enter image description here

最佳答案

这里的大多数答案都是完全错误的,或者在有更简单的方法可以实现相同操作时过于复杂而无法实现。

仅供将来的读者使用 - 您可以在 styles.xml 中更改 textSize/textColor

   <style name="PreferencesTheme" parent="@android:style/Theme.Black">
            <item name="android:textSize">34sp</item>
            <item name="android:textColorSecondary">#000000</item>
            <item name="android:textColorPrimary">#000000</item>
    </style>

其中 textColorPrimary 将更改 checkBoxPreference 标题的颜色,而 textColorSecondary 将更改摘要的颜色。

关于android - 增加 CheckboxPreference 标题和摘要文本大小以及首选项条目的发光,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18787499/

相关文章:

android - 如何删除 TabItem 指示器底部填充?

android - Duolingo 的 RTL ViewPager 覆盖 TabLayout 字体

android - 如何从另一个 Intent 中获取信息?

android - PreferenceActivity 中的 createViewFromResource 出现 NullPointerException

java - 如何从 Cloud firestore 获取数据并使用回收器 View 显示

android - xml 文件中的错误

android - android.widget.ArrayAdapter.createViewFromResource 中的 NullPointerException

android - 在 Android 中使 ListPreference 多项选择的简单方法?

android - AsyncTask 没有锁定主线程?

android - 在没有取消按钮的情况下使用 ListPreference