我在应用程序中使用工具栏来进行材料设计。一切工作正常,但除了更改菜单项文本颜色时,我完全坚持该解决方案。我还发布了应拍摄的文本的屏幕截图以及我在应用程序中使用的代码,以供您参考。我尝试了几种替代方法,例如分配如下
<item name="android:actionMenuTextColor">@color/white</item>
<item name="android:textColor">#000</item>
但已知上述解决方案对我有用。
需求截图:
需要将 SKIP 菜单项从黑色更改为白色。
样式.xml
<style name="ToolBarTheme" parent="@style/Theme.AppCompat.Light">
<item name="colorPrimary">@color/blue</item>
<item name="colorPrimaryDark">@color/blue</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:actionMenuTextColor">@color/white</item>
<item name="android:textColor">#000</item>
</style>
工具栏.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true"
android:background="?attr/colorPrimary"/>
体现
<activity
android:name=".activity.HomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|screenLayout|orientation"
android:theme="@style/ToolBarTheme"></activity>
我真的不知道我哪里犯了错误。请帮我。提前致谢
改变这个
<item name="android:actionMenuTextColor">@color/white</item>
to
<item name="actionMenuTextColor">@color/white</item>
并将主题应用到工具栏:
android:theme="@style/ToolBarTheme"
您可以设置小部件的样式并为您的活动提供主题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)