popwindow的使用总结

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaoyantan/article/details/78323098
  • 实现点击返回键时,popupwindow消失。
    foucs设为true,background 设为colordrawable
PopupWindow popupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  • 实现popupwindow显示时也覆盖住状态栏。
 popupWindow.setClippingEnabled(true);
  • 在Activity的onCreate()方法中不能showPopupwindow的解决。
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
    super.onWindowFocusChanged(hasFocus);
    if(hasFocus){
        showPopupWindow();
    }
}
  • 防止popupwindow被软键盘挡住。
popWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);    
popWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
  • PopupWindow内容区域 响应点击事件.
popupWindow.setTouchable(true);

猜你喜欢

转载自blog.csdn.net/xiaoyantan/article/details/78323098