我正在尝试今晚的新闻主题,我想知道是否有人知道这个问题的解决方法。
当引用自定义布局文件时,它会出现在库存Toolbar上,如下所示。
这是相对较小的,但我的强迫症眼睛是正确的,所以也许有人可以提供帮助。谢谢:))
答案 0 :(得分:6)
更新:继承正确的主题并成对声明属性(包含和不包含android:
前缀)是修复!
<!-- Base app theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles. -->
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:subtitleTextStyle">@style/MyActionBarSubTitleText</item>
<item name="subtitleTextStyle">@style/MyActionBarSubTitleText</item>
<item name="android:background">@color/blue</item>
<item name="background">@color/blue</item>
</style>
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
<style name="MyActionBarSubTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">@dimen/subtitle</item>
</style>
答案 1 :(得分:0)
如果es0329的答案不适合你,请尝试用 titleTextAppearance 替换 titleTextStyle 。它对我有用:
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar">
<item name="android:titleTextAppearance">@style/MyActionBarTitleText</item>
<item name="titleTextAppearance">@style/MyActionBarTitleText</item>
<item name="android:subtitleTextAppearance">@style/MyActionBarSubTitleText</item>
<item name="subtitleTextAppearance">@style/MyActionBarSubTitleText</item>
<item name="android:background">@color/blue</item>
<item name="background">@color/blue</item>
</style>