zoukankan      html  css  js  c++  java
  • Android 设置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>  
  • 相关阅读:
    【luogu2756】 飞行员配对方案问题 [二分图匹配 匈牙利算法]
    [APIO2008]紧急集合
    2019.8.27 Za
    【luogu2763】试题库问题 [网络流 最大流]
    [CQOI2014]危桥 [网络流 最大流]
    【luogu1231】教辅的组成 [网络流 最大流]
    【网络流】
    【2019.8.24】
    【匈牙利算法】
    2019.8.23 Za [数论]
  • 原文地址:https://www.cnblogs.com/xiaoQLu/p/2748246.html
Copyright © 2011-2022 走看看