android自定义透明、无标题的Dialog主题。

在android开发中,系统提供的主题往往不能满足实际开发中的需求,今天我们就来了解一下透明,无标题的Dialog。

首先在res/values目录下建立一个color.xml文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- 透明度 -->
    <color name="transparent">#9000</color>
    
</resources>

设置一个color属性,name自取,#9000代表透明度。

然后在styles.xml文件中设置风格:

<style name="Translucent_Notitle" parent="android:style/Theme.Dialog">
         <item name="android:windowBackground">@color/transparent</item> 
        <item name="android:windowIsTranslucent">true</item>    
        <item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item> 
    </style>

我们给它命名为Translucent_Notitle,parent代表指定其父类为Theme.Dialog。

最后在AndroidManifest.xml文件中修改为自定义的主题:

android:theme="@style/Translucent_Notitle"

ps:佩奇还在学习当中,若有不足需修改之处可以私信哦。

猜你喜欢

转载自blog.csdn.net/qq_41099189/article/details/88872438