一、使用
View popwindowView = LayoutInflater.from(this).inflate(R.layout.popwindow_layout,null);
PopupWindow popupWindow = new PopupWindow(popwindowView, ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,true);
popupWindow.setOutsideTouchable(true);
//必须设置背景不然点击外部popwindow无法消失
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.showAsDropDown(mTvHello);
二、遇到的问题
1、在华为等某些自带虚拟导航栏的手机,PopupWindow 底部被挡住的问题
在setContentView()之后调用:setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
本文介绍了如何在Android中创建并显示PopupWindow,并解决了在带有虚拟导航栏的设备上PopupWindow被遮挡的问题。通过调整setContentView()后的软键盘模式为WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE,可以确保PopupWindow正常显示。
4469

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



