单击OptionMenu时,它会在kitkat上显示黑色背景

时间:2016-06-29 09:48:04

标签: android

当我点击工具栏上的optionMenuItem时,它会显示黑色背景。我在kitkat设备上遇到这个问题,它在棒棒糖和更高的

上工作得很好
    // Toolbar which i am using 

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:local="http://schemas.android.com/apk/res-auto"
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?attr/colorPrimary"
                android:minHeight="?attr/actionBarSize"
                local:popupTheme="@style/MyCustomPopUpTheme"
                local:theme="@style/ToolbarCustomTheme" />


    // MyCustomPopUpTheme theme it works correctly

     <style name="MyCustomPopUpTheme" parent="ThemeOverlay.AppCompat.Light">
            <item name="windowNoTitle">true</item>
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
            <item name="actionMenuTextColor">@color/white</item>
            <item name="android:background">@color/white</item>
            <!--  item for setting the background color of item selected from the list -->
            <item name="listChoiceBackgroundIndicator">@color/white</item>
        </style>

  // ToolbarCustomTheme theme here i am getting issue extending ThemeOverlay.AppCompat.Dark.ActionBar theme

    <style name="ToolbarCustomTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
            <item name="windowNoTitle">true</item>
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
            <item name="actionMenuTextColor">@color/white</item>
            <item name="android:background">@color/colorPrimary</item>
            <item name="background">@color/colorPrimary</item>
        </style>

1 个答案:

答案 0 :(得分:0)

尝试在定义颜色时始终设置alpha。所以如果你想要红色,而不是#ff0000定义#ffff0000。

如果你的@ color / white是一个简单的#ffffff,只需使用预定义的@android:color / white。有几个预定义的。