popuwindow弹出时,背景半透明

1.popuwindow弹出时,弹窗背景是全透明的,可以在其弹出时添加如下代码:

ColorDrawable cds = new ColorDrawable(0x000000);
popupw.setBackgroundDrawable(cds);


WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha = 0.2f;
getWindow().setAttributes(lp);//改变透明度,并重新设置

 

并监听popuwindow消失事件,如果其消失,恢复背景透明度

popupw.setOnDismissListener(new OnDismissListener(){    
   //在dismiss中恢复透明度
   public void onDismiss(){
       WindowManager.LayoutParams lp=getWindow().getAttributes();
       lp.alpha = 1f;
       getWindow().setAttributes(lp);
     }
    });

2.直接把popuwindow背景设置成半透明颜色

ColorDrawable dw = new ColorDrawable(0xb0000000);
popupWindow.setBackgroundDrawable(dw);

 

 

要设置Vant Popup的透明度,可以使用以下方法: 首先,你需要找到Vant Popup的设置透明度的方法。根据你提供的引用,可以看到在PopupWindow的onDismiss方法中恢复透明度的设置。因此,你可以通过在关闭Popup修改透明度来实现设置透明度的效果。 具体步骤如下: 1. 获取当前窗口的属性(WindowManager.LayoutParams)。可以使用getWindow().getAttributes()方法获取。 2. 修改窗口的透明度属性alpha。可以将alpha值设置为所需的透明度,例如0.2f代表20%的透明度。 3. 将修改后的属性重新设置给窗口。可以使用getWindow().setAttributes(lp)方法实现。 通过以上步骤,你可以成功设置Vant Popup的透明度。希望对你有帮助!123 #### 引用[.reference_title] - *1* *2* [popuwindow弹出背景半透明](https://blog.youkuaiyun.com/u011818282/article/details/51611996)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *3* [PopUp半透明叠加层的简单设置](https://blog.youkuaiyun.com/Qiustion/article/details/10992305)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值