【发布时间】:2021-03-28 05:58:22
【问题描述】:
清单为整个应用程序指定一个主题
android:theme="@style/Theme.MyApplication"
在themes.xml中,这个主题继承:
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.Light.NoActionBar"></style>
我将 ToolBar 放在我更改主题的 Activity 中,而不是 ActionBar:
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:theme="@style/ThemeForMyMenu"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#47A0FF"/>
在themes.xml中,ThemeForMyMenu的描述如下:
<style name="ThemeForMyMenu" parent="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar">
<item name="android:actionMenuTextColor">#000000</item>
</style>
结果,我为整个应用程序使用了浅色主题,为工具栏使用了深色主题,在其中我将 actionMenuTextColor 更改为黑色。我创建了一个菜单文件,在其中创建了两个项目。一项显示在工具栏上,另一项保留在菜单中
<item android:title="О программе"
app:showAsAction="always"
android:id="@+id/about"
/>
<item android:title="Выход"
android:id="@+id/exit"
app:showAsAction="never"/>
显示在工具栏上的项目变成黑色(#000000),并且保留在菜单中的项目为白色并与菜单背景合并(不可见)。我需要更改菜单文本颜色和菜单背景颜色。我找不到办法做到这一点。告诉我如何更改文本颜色(菜单内)和菜单的背景颜色
【问题讨论】:
标签: java android android-actionbar themes android-theme