android设置背景色为透明

方法一:

只要在配置文件内activity属性配置内加上

android:theme="@android:style/Theme.Translucent"

就好了。

这样就调用了android的透明样式!

方法二:

先在res/values下建colors.xml文件,写入:
  
  <?xmlversion="1.0"encoding="UTF-8"?>
  
  <resources>
  
  <colorname="transparent">#9000</color>
  
  </resources>
  
  这个值设定了整个界面的透明度,为了看得见效果,现在设为透明度为56%(9/16)左右。
  
  再在res/values/下建styles.xml,设置程序的风格
  
  <?xmlversion="1.0"encoding="utf-8"?>
  
  <resources>
  
  <stylename="Transparent">
  
  <itemname="android:windowBackground">@color/transparent</item>
  
  <itemname="android:windowIsTranslucent">true</item>
  
  <itemname="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
  
  </style>
  
  </resources>
  
  最后一步,把这个styles.xml用在相应的Activity上。即在AndroidManifest.xml中的任意<activity>标签中添加
  
  android:theme="@style/transparent"
  
  如果想设置所有的activity都使用这个风格,可以把这句标签语句添加在<application>中。
  
  可以把背景色#9000换成#0000,运行程序后,就全透明了

更多相关文章

  1. Android设置任何控件透明度
  2. Android TabHost风格
  3. Android风格设计(style)
  4. AndroidMainifest标签使用说明3——<activity-alias>
  5. Android第三十八期 - 评价标签FlowLayout
  6. Android对话框的高级设置《二》设置对话框按钮的透明度和对话框
  7. android shape设置背景风格为圆角
  8. 二十二、android中application标签说明
  9. android 更改密码显示风格

随机推荐

  1. 【android】/storage/sdcard, /sdcard, /mn
  2. Android(安卓)MVVM+DataBinding结合Dagge
  3. 全志A10平板电脑安装ubuntu 10.04LTS(与An
  4. 安卓开发_浅谈Android动画(二)
  5. Android(安卓)MaskedImage
  6. Android中SQLite的陷阱
  7. Android(安卓)Studio 与svn
  8. 用git 下载android x86出错(syntax error
  9. 如何往Android中整合开发程序 doubango框
  10. android设置toolbar的menu itemTextView