简体   繁体   中英

How to change popup menu color in matetial3

How can i change popup menu background color in material3. I have tried a lot but found no solutions. I had tried itemBacgroundColor also but it's still in different color. I want it to white.

https://i.stack.imgur.com/gy1EQ.jpg

I don't sure about material, but you can change color of pop up menu like this:

add your style

    <style name="popupMenuStyle" parent="Widget.AppCompat.PopupMenu">
        <item name="android:background">@color/white</item>
    </style>

and when you init popup menu

val cornerPopupWrapper =ContextThemeWrapper(requireContext(),R.style.popupMenuStyle)
val popupMenu = PopupMenu(cornerPopupWrapper, it, Gravity.NO_GRAVITY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM