
android怎么实现自定义对话框的背景
2个回答
展开全部
1. 在res/values下创建两个xml文件,一个为主体风格资源styles.xml一个为颜色资源colors.xml
styles.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name = "translucent" parent = "@android:style/Theme.Dialog">
<item name = "android:windowBackground">@color/translucent_background</item>
<item name = "android:windowIsTranslucent">true</item>
<item name = "android:windowNoTitle">true</item>
<item name ="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
</style>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name = "translucent_background">#00000000</color>
</resources>
2. 在AndroidManifest.xml为Activity指定自定义的主题
<activity android:name = “.copyright” android:theme = “@style/translucent” />
3. 在显示图片的activity布局文件中加入图片资源(设置layout的背景或者增加一个ImageView显示图片)
4.在Activity java文件copyright.java中关联布局文件,然后运行Android工程到此activity.
styles.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name = "translucent" parent = "@android:style/Theme.Dialog">
<item name = "android:windowBackground">@color/translucent_background</item>
<item name = "android:windowIsTranslucent">true</item>
<item name = "android:windowNoTitle">true</item>
<item name ="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
</style>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name = "translucent_background">#00000000</color>
</resources>
2. 在AndroidManifest.xml为Activity指定自定义的主题
<activity android:name = “.copyright” android:theme = “@style/translucent” />
3. 在显示图片的activity布局文件中加入图片资源(设置layout的背景或者增加一个ImageView显示图片)
4.在Activity java文件copyright.java中关联布局文件,然后运行Android工程到此activity.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询