【发布时间】:2019-11-28 04:13:44
【问题描述】:
起初,我的应用程序使用<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 样式。但我将其更改为 Material Components <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">(为了使用标签的 Material 徽章计数)。所以改变后的样式是这样的:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/green</item>
<item name="colorAccent">@color/green</item>
</style>
更改样式后,溢出菜单背景现在为白色。 (之前是带有白色文字的绿色背景Theme.AppCompat.Light.DarkActionBar)。但是现在背景是白色的,文字也是白色的。
这里是工具栏的xml:
<androidx.appcompat.widget.Toolbar
android:id="@+id/ev_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ToolbarTheme">
</androidx.appcompat.widget.Toolbar>
工具栏的主题风格:
<style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">@color/white</item>
<item name="android:colorBackground">@color/green</item>
</style>
我尝试在AppTheme 中设置<item name="popupMenuStyle">@style/CustomPopup</item>
<style name="CustomPopup" parent="@style/Widget.MaterialComponents.PopupMenu">
<item name="android:popupBackground">@color/green</item>
</style>
但还是没有运气。
我用来测试的设备是Android 8.0,compileSdkVersion和targetSdkVersion是28。
感谢您的宝贵时间。
【问题讨论】:
标签: android xml android-theme material-components material-components-android