使用 AppCompat 更改 ActionBar 文本颜色
Change ActionBar text color using AppCompat
我正在尝试像这样更改 ActionBar 文本颜色。
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
根据很多 similar topics (another one) 这应该可行,但是 none 改变了文本颜色,而且当我尝试这个时我的 ActionBar 变得透明。我可以通过更改 AppTheme 中的 textColorPrimary 来更改它的文本颜色,但它也改变了很多东西。
此外,我还想查看有关 android 中样式如何工作的任何链接,因为它的层次结构让我有点困惑
你为什么不使用 ToolBar xml 像这样
<android.support.v7.widget.Toolbar
android:id="@+id/videos_toolbar"
style="@style/ToolBarTextStyle"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
android:layout_alignParentTop="true"
android:background="@color/ToolBarColor"
android:paddingRight="@dimen/_32sdp"
android:textAlignment="center"
app:titleTextColor="@color/ThemeColor">
我正在尝试像这样更改 ActionBar 文本颜色。
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
根据很多 similar topics (another one) 这应该可行,但是 none 改变了文本颜色,而且当我尝试这个时我的 ActionBar 变得透明。我可以通过更改 AppTheme 中的 textColorPrimary 来更改它的文本颜色,但它也改变了很多东西。
此外,我还想查看有关 android 中样式如何工作的任何链接,因为它的层次结构让我有点困惑
你为什么不使用 ToolBar xml 像这样
<android.support.v7.widget.Toolbar
android:id="@+id/videos_toolbar"
style="@style/ToolBarTextStyle"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
android:layout_alignParentTop="true"
android:background="@color/ToolBarColor"
android:paddingRight="@dimen/_32sdp"
android:textAlignment="center"
app:titleTextColor="@color/ThemeColor">