wei*_*yin 57 android android-appcompat android-actionbar android-actionbar-compat material-design
我正在使用v7 appcompat 21库在pre-Lollipop设备上使用新的Material样式.我的styles.xml看起来像这样:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">#ff0000</item>
<item name="android:textColorPrimaryInverse">#ff0000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我正在尝试更改操作栏上的文本颜色.但无论我为textColorPrimary或textColorPrimaryInverse提供什么,颜色总是白色的.如果我继承自Theme.AppCompat,我可以覆盖"textColorPrimary",如果我从Theme.AppCompat.Light继承,我可以覆盖"textColorPrimaryInverse".但是在使用Light.DarkActionBar主题时都不起作用.
我肯定使用AppTheme,因为设置像colorPrimary这样的属性来改变动作栏背景颜色很好.我没有使用任何其他资源限定符样式文件.
我已经挖掘了android样式文件,似乎无法弄清楚要覆盖的属性.有任何想法吗?这是appcompat错误吗?
jim*_*251 165
您可以使用actionBarStyle主题属性更改它.
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">@style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">CHANGE_COLOR_HERE</item>
</style>
Run Code Online (Sandbox Code Playgroud)
vov*_*ost 26
这将使您的工具栏标题使用白色:
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
Run Code Online (Sandbox Code Playgroud)
要了解有什么区别ThemeOverlay.AppCompat.Dark.ActionBar并Theme.AppCompat.Light.DarkActionBar检查 这个答案
这app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"是应用浅色,因为在这个主题中使用的标题颜色是白色.
| 归档时间: |
|
| 查看次数: |
58880 次 |
| 最近记录: |