美文网首页
popupwindow遇到的奇葩问题-点击返回键不消失(6.0一

popupwindow遇到的奇葩问题-点击返回键不消失(6.0一

作者: 恋若夏 | 来源:发表于2016-10-11 18:17 被阅读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自动消失

相关文章

网友评论

      本文标题:popupwindow遇到的奇葩问题-点击返回键不消失(6.0一

      本文链接:https://www.haomeiwen.com/subject/dzybyttx.html