简书链接:toolbar弹出菜单颜色被theme影响问题分析记录
文章字数:86,阅读全文大约需要1分钟
1 2 3 4 5 6 7 8 9 10 11 12
| <androidx.appcompat.widget.Toolbar style="@style/ToolbarStyle" android:id="@+id/toolBar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" android:theme="@style/ToolbarTheme" app:navigationIcon="@drawable/ic_menu_back" app:popupTheme="@style/TooolbarPopTheme" app:titleTextColor="@android:color/white" />
|
如果只是修改背景,而不修改弹出背景应该直接在xml中或者再 style中定义,而不应该在 theme 引用中定义
1 2 3 4 5 6
| <style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.Light">
<item name="colorControlNormal">@color/white_no_night</item> </style>
|
1 2 3 4 5 6
| <style name="ToolbarStyle"> <item name="android:background">?attr/defaultThemeColor</item>
</style>
|
1 2 3 4 5 6 7
| <style name="TooolbarPopTheme"> <item name="actionOverflowButtonStyle">@style/Widget.AppCompat.PopupMenu.Overflow</item> </style>
|