如何删除菜单弹出窗口周围的圆形边框?

问题描述

当您单击屏幕右上角的三个点时,我的应用会弹出一个菜单。出于某种原因,菜单项周围有一个圆形边框。我看过其他 android 应用程序,它们没有这个边框。我使用 Android Studio 上的基本活动模板来获取菜单

Weird border around menu,shown more clearly by clicking an item

我看了菜单xml文件的预览,没有边框。

Popup as shown in xml preview

如何移除此边框?

解决方法

你可以试试这个。

// set your activity style add popup style 
<item name="android:popupMenuStyle" >@style/myPopupMenu</item>
// your popup style in "style.xml"
<style name="myPopupMenu" parent="@style/Widget.AppCompat.PopupMenu">
    <item name="android:popupBackground">@drawable/shape_menu</item>
</style>

// "shape_menu" drawable in your "drawable/shape_menu.xml",radius is rounded border
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="0dp" />
    <solid android:color="@color/white" />
</shape>