//创建popupWindow
popupWindow = new PopupWindow(getActivity());
//加载popupWindow布局
View inflate = View.inflate(getActivity(), R.layout.home_pop_item, null);
popupWindow.setContentView(inflate);
//设置popupWindow宽高
popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
//设置可触碰
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
popupWindow.setTouchable(true);
//设置显示位置
popupWindow.showAsDropDown(ivMenu);
//设置popupWindow关闭
popupWindow.dismiss();
popupWindow.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
popupWindow.dismiss();
return true;
}
return false;
}
});
PopupWindow的基本应用
猜你喜欢
转载自blog.csdn.net/qq_41423726/article/details/86549225
今日推荐
周排行