Android PopupWindow 部分机型(魅族)点击外部不能取消的bug

版权声明:本文为博主原创文章,转载请附原博客地址。侵权必究 https://blog.csdn.net/wapchief/article/details/82736206

解决办法:
在showAs之前设置setBackgroundDrawable(new BitmapDrawable());

完整代码:


LayoutInflater inflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final ShadowLayout layout = (ShadowLayout) inflater.inflate(R.layout.popup_notes, null);
        optionsPopWindow = new PopupWindow(layout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, true);
        optionsPopWindow.setContentView(layout);
        optionsPopWindow.setBackgroundDrawable(new BitmapDrawable());
        optionsPopWindow.showAsDropDown(view);
        layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

猜你喜欢

转载自blog.csdn.net/wapchief/article/details/82736206