笔记:popupwindow使用

来源:互联网 发布:阿里云maven配置文件 编辑:程序博客网 时间:2024/04/28 07:14
public void showPopupWindow(final View anchor, int flag) {    final PopupWindow popupWindow = new PopupWindow(FindJobActivity.this);    //一个自定义的布局,作为显示的内容    View contentView = LayoutInflater.from(FindJobActivity.this).inflate(R.layout.popupwindow_findjob, null);
popupWindow.setOnDismissListener(this); //消失时调用此方法popupWindow.setWidth(screenWidth);popupWindow.setHeight(screenHeight);popupWindow.setContentView(contentView);popupWindow.setFocusable(true);popupWindow.setOutsideTouchable(true);//如果不设置背景,无论点击外部区域还是back键都无法dismiss弹框popupWindow.setBackgroundDrawable(new PaintDrawable()); popupWindow.showAsDropDown(anchor);//显示在一个参照物View的周围
setFocusable(true)保证popupwindow中的listview能点击,不被父布局拦截
0 0
原创粉丝点击