popupwindow设置全屏边缘仍然有缝隙

bug如图:

popupwindow设置全屏边缘仍然有缝隙_第1张图片

popupwindow设置全屏边缘仍然有缝隙_第2张图片


边缘仍然有缝隙   具体原因不清楚  暂时记录一下解决办法:设置背景

setBackgroundDrawable(new BitmapDrawable());
效果图:
 
  
整个popupwindow设置为全屏,然后添加了一个铺满的viewgroup  再加入固定大小的view
 
  
最后贴上核心代码:
 
  
this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
this.setBackgroundDrawable(new BitmapDrawable());// 这样设置才能铺满屏幕,去掉这句话会出现缝隙
this.setOutsideTouchable(true);
this.setFocusable(true);
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.MATCH_PARENT);
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(CommonUtil.dp2px(context, 844), CommonUtil.dp2px(context, 527));

RelativeLayout root = new RelativeLayout(context);
root.setLayoutParams(params1);
root.setBackgroundColor(Color.parseColor("#99000000"));
RootView rootView = new RootView(context);
rootView.setLayoutParams(params2);
params2.addRule(RelativeLayout.CENTER_IN_PARENT);
root.addView(rootView);

this.setContentView(root);

 
  
记录贴!

你可能感兴趣的:(popupwindow设置全屏边缘仍然有缝隙)