Material-components-android: [Popup Menu Option]

Created on 10 Nov 2019  路  10Comments  路  Source: material-components/material-components-android

Description: I got an issue in the alpha version especially when we use the dark theme in an Android application. Please let me know and see the bug in the screenshot. Everywhere is black but only the popup menu shows some extra width around the menu.

Material Library version: Material Android Library version currently am using here ( implementation 'com.google.android.material:material:1.2.0-alpha01'`)

Device: Samsung Galaxy J6 Infinity

ScreenShot:
Screenshot_20191110-183124_Ai

To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

bug

Most helpful comment

Hy i am also facing exact same issue ... in my case library version is stable
implementation 'com.google.android.material:material:1.0.0'

All 10 comments

Could you provide the source code/a sample app where the issue happens?

You can see the popup white color where the word is written Settings in the above screenshot. There is background white and black. Also, its height isn't less. Its height is more. Have any solution

Source:

override fun onCreateOptionsMenu(menu: Menu): Boolean {
        val inflater: MenuInflater = menuInflater
        inflater.inflate(R.menu.main_menu_activity, menu)
        return true
    }
override fun onOptionsItemSelected(item: MenuItem): Boolean {
        return when (item.itemId) {
            R.id.settings -> {
                this.startActivity(Intent(this, SettingsActivity::class.java))
                return true
            }
            else -> super.onOptionsItemSelected(item)
        }
    }

Hey there. It would be great to get a complete, minimal sample app (including themes, styles, etc) that reproduces this issue so we can investigate where this is coming from.

@hunterstich Thanks for writing to me. Sure Everything I had complete write on the above message. Now I will be writing the theme or style code which is using for dark mode.


<style name="DarkModeTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="colorPrimary">#212121</item>
        <item name="colorPrimaryDark">#FC031113</item>
        <item name="colorAccent">#2196F3</item>
        <item name="backgroundColor">#F3020202</item>
        <item name="cardBackground">#FC1B1B1B</item>
        <item name="textColor">#ffffff</item>
        <item name="tintColor">#E9000000</item>
        <item name="buttonColor">#2196F3</item>
        <item name="viewColor">#3A3A3A</item>
        <item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
        <item name="iconTint">#ffffff</item>
        <item name="android:itemBackground">#F2000000</item>
        <item name="android:textColor">#ffffff</item>
        <item name="popupMenuStyle">@style/Widget.MaterialComponents.PopupMenu</item>
        <item name="actionOverflowMenuStyle">@style/Widget.MaterialComponents.PopupMenu.Overflow</item>
    </style>

Other rest of the code I already mentioned above including the dependency any other let me know.

implementation 'com.google.android.material:material:1.2.0-alpha01'

Menu.xml code is

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/settings"
        android:title="@string/settings"
        app:showAsAction="never"/>
</menu>

Hy i am also facing exact same issue ... in my case library version is stable
implementation 'com.google.android.material:material:1.0.0'

I'm also facing the same problem. In my case the stable library version is
also 1.0.0

try using
<item name="popupMenuBackground">#F2000000</item>
on your style

On material 1.2.1 I could solve this problem only with

<item name="actionBarPopupTheme">@style/actionBarPopup</item>

<style name="actionBarPopup" parent="Widget.MaterialComponents.PopupMenu">
<item name="android:background">@color/transparent</item> (needed for smooth animation, otherwise it draws the view before populating the menu with items)
<item name="popupMenuBackground">@color/{color}</item>
</style>

Could someone please confirm whether the bug is in the latest 1.3.x version of the lib? Thanks!

try using
<item name="popupMenuBackground">#F2000000</item>
on your style

I have tried then asking you

Was this page helpful?
0 / 5 - 0 ratings