android - 在 AppCompat 主题中设置标题颜色

标签 android android-theme

我想知道如何为我的 PreferenceFragment 中的标题设置颜色它使用新的 AppCompat主题。我的设置截图Fragment ,这extends PreferenceFragment , 如下图所示:

enter image description here

我可以设置 ActionBar 的颜色通过使用 colorPrimary属性,以及主要和次要文本的颜色,使用 android:textColorandroid:textColorSecondary属性,分别。但是,我不知道如何设置标题的颜色 - 任何帮助将不胜感激。

最佳答案

我正在使用这个(你也可以删除 .Inverse):

android:textAppearance="@style/TextAppearance.AppCompat.Subhead.Inverse"

在我的标题中我使用了 colorAccent,然后:

android:textColor="?attr/colorAccent"

我所有的 TextView:

       <TextView
                android:id="@+id/textViewAdvancedSetting"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="24dp"
                android:layout_marginRight="24dp"
                android:layout_marginTop="16dp"
                android:fontFamily="sans-serif-medium"
                android:gravity="center_vertical"
                android:text="Advanced Settings"
                android:textAppearance="@style/TextAppearance.AppCompat.Subhead.Inverse"
                android:textColor="?attr/colorAccent"
                android:textSize="14sp" />

它的图像(jellybean、kitkat 和 lollipop),黑色边框是模拟器:

enter image description here

关于android - 在 AppCompat 主题中设置标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28160452/

相关文章:

android - PlacePicker 不选择 Material 主题

android - 我的 Android 应用程序的在线样式和主题资源?

Android AudioTrack 对象不会播放安静的正弦信号(低于大约 15 分贝)

java - 错误 : javax. crypto.BadPaddingException:解密时填充 block 损坏

android - fontFamily 无法在 androidx 上运行

android - 在 Android O 上切换状态栏颜色的问题

android - 实现用户选择主题

android - "Error inflating class menu"- android.view.InflateException : Binary XML file line #119: Error inflating class menu

android - 启动 map 时出现运行时错误

Android 和 ResponseCache...请求 header 丢失