为ListPopupWindow去除阴影

ListPopupWindow默认是有一个阴影效果的,如果需要去除。可以看到ListPopupWindow本身的构造方法。

public ListPopupWindow(@NonNull Context context) {
    this(context, null, R.attr.listPopupWindowStyle);
}

应用了listPopupWindowStyle这个属性,这个默认的style可以在value下面找到


为ListPopupWindow去除阴影_第1张图片
image.png

这个主题的默认属性如下


为ListPopupWindow去除阴影_第2张图片

popupElevation
这个属性在Api21及以上的默认的值是


image.png

所以会有阴影效果出现。如果需要去掉阴影,可以在

value-21

下新建style文件,其实也不一定是21,默认下面也是可以的,但是Elevation是API21才有的属性,会有提示。不太好。

 

然后在AppTheme下设置

 @style/listpopstyle

全局的ListPopupWindow就都达到了这种效果。其他的更多属性类似。

你可能感兴趣的:(为ListPopupWindow去除阴影)