popwindow背景色设置

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiayong1/article/details/53191529

// 实例化一个ColorDrawable颜色

ColorDrawable dw = newColorDrawable(mContext.getResources().getColor(R.color.blue));

// 设置弹出窗体的背景

this.setBackgroundDrawable(dw);

setWidth(ViewGroup.LayoutParams.MATCH_PARENT);

setHeight(ViewGroup.LayoutParams.MATCH_PARENT);


//通常popwindow中会加上以下语句

setTouchable(true);

setFocusable(true);


使用以上方法设置了背景颜色后,在popwindow的布局文件中注意不要另外再设置整个popwindow的背景颜色,否则会两个颜色重叠,而且会有闪烁效果




猜你喜欢

转载自blog.csdn.net/xiayong1/article/details/53191529