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);
// 設(shè)置彈出窗體的寬和高
this.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
this.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
// 設(shè)置彈出窗體可點擊
this.setFocusable(true);
// 設(shè)置外部可點擊
this.setOutsideTouchable(true);
}
這是我自定義的popwindow,顯示正常,但是在6.0以下機(jī)器上點擊返回鍵,pop不自動消失,監(jiān)聽不到返回鍵的操作(onKeyDonw() 和 onBackPressed()方法均未觸發(fā)),具體原因不詳,解決辦法:對popwindow設(shè)置this.setBackgroundDrawable(newBitmapDrawable())問題解決,點擊返回鍵,pop自動消失