android怎么自定义对话框

如题所述

  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.
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜