Search code examples
javaandroidandroid-fragmentsandroid-toolbar

Remove Transparent Background in Toolbar Fragment


I am using a toolbar in which the overflow menu options have a transparent background as shown in the image transparent overflow menu in toolbarenter image description here

I have tried editing the default theme and also tried out a custom theme as well as using a panel background option. Could someone please let me know how to make the background of the overflow menu in the toolbar not transparent?


Solution

  • change your base theme as below one it should work as its working for me just compiled now. just add this

    <item name="android:itemBackground">@color/colorPrimaryDark</item>
    

    Theme:

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:itemBackground">@color/colorPrimaryDark</item>
    </style>