好久没有使用popupWindow,今天为实现一个功能,可耽误了我一些时间
下面是popupWindow的基本设置
mSubColumnPop = new PopupWindow(getActivity());
mSubColumnPop.setContentView(layout); //这个是设置自定义的view
mSubColumnPop.setOutsideTouchable(true); //外部可点击
mSubColumnPop.setBackgroundDrawable(new BitmapDrawable()); //必须设置,否则外部点击不消失
mSubColumnPop.setFocusable(true); //必须设置
mSubColumnPop.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT); //必须设置
mSubColumnPop.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); //必须设置
LogUtils.e("弹出子栏目");
mSubColumnPop.showAtLocation(mSubColumn,Gravity.BOTTOM,-mFilter.getWidth()+50,mSubColumn.getHeight()+10);宽高不设置,有时候在高版本的时候可以显示,但是到了低版本就显示不了啦
有两个调整位置的方法 showAtLocation ---- 可以调整到自己想要的位置
//在某个控件的下发
mSubColumnPop.showAsDropDown();
本文详细介绍了如何设置和显示PopupWindow,包括自定义视图、触摸反馈、焦点管理及宽高设定等内容,并提供了两个调整位置的方法:showAtLocation 和 showAsDropDown。

被折叠的 条评论
为什么被折叠?



