popupwindow遇到的奇葩问题-点击返回键不消失(6.0一下版本都有该问题)

publicBottomPopupWindow(Contextcontext,intlayoutId){

this.mContext=context;

initView(layoutId);

this.setAnimationStyle(R.style.underPopUpWindowAnim);

}

publicBottomPopupWindow(Contextcontext,intlayoutId,intstyleId){

this.mContext=context;

initView(layoutId);

this.setAnimationStyle(styleId);

}

private voidinitView(intlayoutId){

this.view= LayoutInflater.from(mContext).inflate(layoutId,null);

this.setContentView(this.view);

// 设置弹出窗体的宽和高

this.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);

this.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);

// 设置弹出窗体可点击

this.setFocusable(true);

// 设置外部可点击

this.setOutsideTouchable(true);

}

这是我自定义的popwindow,显示正常,但是在6.0以下机器上点击返回键,pop不自动消失,监听不到返回键的操作(onKeyDonw() 和 onBackPressed()方法均未触发),具体原因不详,解决办法:对popwindow设置this.setBackgroundDrawable(newBitmapDrawable())问题解决,点击返回键,pop自动消失

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容