美文网首页
全透明背景

全透明背景

作者: zyco | 来源:发表于2017-09-20 10:14 被阅读156次

全透明背景

<style name="Transparent_Dialog" parent="android:style/Theme.Dialog">
     <!--背景颜色及透明程度-->
     <item name="android:windowBackground">@android:color/transparent</item>
     <!--是否有标题 -->
     <item name="android:windowNoTitle">true</item>
     <!--是否浮现在activity之上-->
     <item name="android:windowIsFloating">true</item>
     <!--是否模糊-->
     <item name="android:backgroundDimEnabled">false</item>
     <!--是否显示边框-->
     <item name="android:windowFrame">@null</item>
 </style>

progressbar.xml

<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/progress_bar_size"
    android:layout_height="@dimen/progress_bar_size"
    android:background="@drawable/dialog_loading_background"
    android:indeterminateDrawable="@drawable/progress_bar_drawable"
    android:padding="@dimen/default_padding_margin" />

dialog_loading_background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 设置四个角的半径 -->
    <corners android:radius="16dp"/>

    <!-- 填充 -->
    <solid android:color="#66000000"/>

   
</shape>

progress_bar_drawable.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="720">

    <shape
        android:innerRadiusRatio="3"
        android:shape="ring"
        android:thicknessRatio="15"
        android:useLevel="false">

        <gradient
            android:centerY="0.50"
            android:endColor="#FFFFFF"
            android:startColor="#999999"
            android:type="sweep"
            android:useLevel="false" />
    </shape>

</rotate> 

android:innerRadiusRatio="3" 表示内环半径为环半径除以3
android:thicknessRatio="15" 表示环厚度为环半径除以15
gradient是shape的颜色渐变属性,type有三类,linear是线性,radial是由中心向外渐变的,sweep是扫描式渐变
android:useLevel:只有当我们的shape使用在LevelListDrawable中的时候,这个值为true,否则为false

取宽度的20%和高度的80%的位置 android:centerX="0.2" android:centerY="0.8"

相关文章

网友评论

      本文标题:全透明背景

      本文链接:https://www.haomeiwen.com/subject/iyunsxtx.html