Android Question ACPopupMenu black border on API level 22

Discussion in 'Android Questions' started by Yuri Cinesi, Jan 23, 2018.

  1. Yuri Cinesi

    Yuri Cinesi Member Licensed User

    I'm using appcompat to create a popup menu using ACPopupMenu, with Theme.AppCompat.Light.NoActionBar as the base theme I've then modified.
    On android 5.0.1 (API 22) however there is a strange black border around the popup menu when it's shown. The same thing does not happen on 7.1 (API 25) and the menu is displayed correctly.
    Any ideas on how to remove the black border?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you post a screenshot and a small project that demonstrates it?
     
  3. Yuri Cinesi

    Yuri Cinesi Member Licensed User

    Here's everything.
     

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

    It looks like this Android 5.0 bug: https://stackoverflow.com/questions...ollipop-popup-menu-when-using-dark-background

    Try it with this style:
    Code:
    CreateResource(values, theme.xml,
    <resources>
        <style name=
    "MyAppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
            <item name=
    "windowNoTitle">true</item>
           <item name=
    "windowActionBar">false</item>
           <item name=
    "textAppearanceLargePopupMenu">@style/myPopupMenuTextAppearanceLarge</item>
           <item name=
    "android:textAppearanceLargePopupMenu">@style/myPopupMenuTextAppearanceLarge</item>
           <item name=
    "textAppearanceSmallPopupMenu">@style/myPopupMenuTextAppearanceSmall</item>
           <item name=
    "android:textAppearanceSmallPopupMenu">@style/myPopupMenuTextAppearanceSmall</item>
           <item name=
    "popupMenuStyle">@style/myPopupMenuStyle</item>
           <item name=
    "android:popupMenuStyle">@style/myPopupMenuStyle</item>
        </style>
         
       <style name=
    "myPopupMenuStyle" parent="@style/Widget.AppCompat.Light.PopupMenu">
           <item name=
    "android:popupBackground">@drawable/my_popup_bg</item>
       </style>
       <style name=
    "myPopupMenuTextAppearanceSmall" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Small">
           <item name=
    "android:textColor">#FFFFFF</item>
       </style>
       <style name=
    "myPopupMenuTextAppearanceLarge" parent="@style/TextAppearance.AppCompat.Light.Widget.PopupMenu.Large">
           <item name=
    "android:textColor">#FFFFFF</item>
       </style>
    </resources>
    )
    CreateResource(drawable, my_popup_bg.xml,
    <shape xmlns:android=
    "http://schemas.android.com/apk/res/android"
           android:shape=
    "rectangle">
        <corners android:radius=
    "2dp" />
        <solid android:color=
    "#002C74" />
    </shape>
    )
     
  5. Yuri Cinesi

    Yuri Cinesi Member Licensed User

    Works perfectly. Many thanks.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice