Change Popup menu background color

后端 未结 10 1445
执念已碎
执念已碎 2020-12-05 11:28

NOTE: I have searched for an hour and tried all solutions already provided by stackoverflow.

I am studying theme over

相关标签:
10条回答
  • 2020-12-05 12:00

    Try it out

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
            <item name="android:colorBackground">@color/white</item>
            <item name="android:textColor">@color/grey_900</item>
        </style>
    
    0 讨论(0)
  • 2020-12-05 12:02

    Add popupMenu style to ur AppTheme:

    <style name="AppTheme" parent="android:Theme.Light">
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
    </style>
    
    <style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:popupBackground">@android:color/white</item>
    </style>
    

    manifest.xml:

     <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
    .............
    </application>
    

    i hope it will work.

    0 讨论(0)
  • 2020-12-05 12:07

    This worked for me

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

    Insert that into your main style I hope this works for you

    0 讨论(0)
  • 2020-12-05 12:08
    <style name="YOURSTYLE" parent="Widget.AppCompat.PopupMenu">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:itemBackground">@android:color/holo_red_light</item>
    </style>
    
    Context wrapper = new ContextThemeWrapper(this, R.style.YOURSTYLE);
    PopupMenu popup = new PopupMenu(wrapper, view);
    

    May be its helps you

    0 讨论(0)
  • 2020-12-05 12:08

    None of the above solutions worked for me, so this is how I fixed it:

    First of all make a new Theme for the Activity, and:

    <style name="Theme.YourTheme" parent="Theme.AppCompat">
        <item name="android:itemBackground">@color/white</item>
        <item name="android:textColor">@color/black</item>
    </style>
    
    1. To make the background of items white

      <item name="android:itemBackground">@color/white</item>
      
    2. To counter make the text color black

      <item name="android:textColor">@color/black</item>
      

    Lastly, apply the theme to your Activity via Manifest:

        <activity android:name=".YourActivity"
            android:theme="@style/Theme.YourTheme"/>
    
    0 讨论(0)
  • 2020-12-05 12:12

    Use popupTheme from AppCompat toolbar

     <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:popupTheme="@style/MyTheme"/>
    

    In Style :

      <style name="MyTheme" parent="ThemeOverlay.AppCompat.Light">
        <item name="android:colorBackground">@color/colorPrimary</item>
        <item name="android:textColor">@color/white</item>
    </style>
    

    Hope it will work.

    0 讨论(0)
提交回复
热议问题