打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
dialog的全透明无边框背景

做dialog的全透明无边框背景,网上找了n久,都有问题,其实很简单,就两句搞定。

<style name="Translucent_NoTitle" parent="android:style/Theme.Dialog"><item name="android:background">#00000000</item> <!-- 设置自定义布局的背景透明 --><item name="android:windowBackground">@android:color/transparent</item>  <!-- 设置window背景透明,也就是去边框 --></style>

 

其他的都可以不用设置,有些属性会继承下来,唯一一个没被继承的是 <item name="android:windowIsTranslucent">true</item>,这个不设置也没影响
 
此方法同样可以用于activity,设置activity半透明
res/values/styles.xml<resources>    <style name="Transparent  ">      <item name="android:windowBackground">@color/transparent_background</item>      <item name="android:windowNoTitle">true</item>      <item name="android:windowIsTranslucent">true</item>        <item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>    </style>  </resources>  
 res/values/color.xml<?xml version="1.0" encoding="utf-8"?>  <resources>    <color name="transparent_background">#50000000</color>  </resources>  

注意:color.xml的#5000000前两位是透明的效果参数从00--99(透明--不怎么透明),后6位是颜色的设置 

manifest.xml<activity android:name=".TransparentActivity" android:theme="@style/Transparent">  </activity>  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Android有趣的全透明效果--Activity及Dialog的全透明(附android...
自定义progressdialog
Android 设置Activity透明
Android Styles & Themes(下)
Android应用开发中的风格和主题(style,themes)
Android风格与主题
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服