Android设置背景色为透明
来源:互联网 发布:小米6相机优化 编辑:程序博客网 时间:2024/05/20 21:21
方法一:
- 只要在AndroidManifest文件中activity属性配置内加上android:theme="@android:style/Theme.Translucent" 就好了。这样就调用了android的透明样式!
- android:theme="@android:style/Theme.Translucent.NoActionBar"没有ActionBar的透明样式。
方法二:
先在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,运行程序后,就全透明了,看得见背景下的所有东西可以却都操作无效。
- android设置背景色为透明
- android设置背景色为透明
- android设置背景色为透明
- android设置背景色为透明
- Android设置背景色为透明
- android设置背景色为透明
- android设置背景色为透明,Button控件透明
- android设置背景色为全透明和半透明
- 设置QListWidget背景色为透明
- 设置UILabel的背景色为透明
- 设置QListWidget背景色为透明
- activity设置背景色为透明
- Android开发(37) android设置Activity背景色为透明的3种方
- 设置窗体上控件的背景色,设置控件背景色为透明
- android设置Activity背景色为透明的2种方法
- android设置Activity背景色为透明的2种方法
- android设置Activity背景色为透明的3种方
- android设置Activity背景色为透明的2种方法
- 四大组件之Activity的瘦身版Fragment(片段)
- iOS界面布局之三——纯代码的autoLayout及布局动画 iOS8及VFL语言
- java集合框架图
- 自动化测试使用mybatis更新数据库信息实例
- 【DP/单调栈】关于单调栈的一些题目(codevs 1159,codevs 2673)
- Android设置背景色为透明
- 手机移动广告打头阵助力移动营销成功
- 数据库sql中and和or优先级的问题
- 文章标题
- 【概率】BZOJ 3450:Tyvj1952 Easy
- Web-Scale IT:对企业的影响
- Spring 读取properties文件
- 使用微信JSSDK自定义微信分享标题、描述时需要注意的问题
- ajax返回json格式时,中文乱码问题,以问号形式呈现