android设置背景色为透明
2015-06-05 14:52
411 查看
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,运行程序后,就全透明了
方法一:
只要在配置文件内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,运行程序后,就全透明了
相关文章推荐
- android paint 研究总结
- 中国气象网 气象数据开放平台 API使用方法 (Android)
- android 无法生成R文件的原因剖析
- Android中滑屏实现----手把手教你如何实现触摸滑屏以及Scroller类详解
- Android定位开发之百度定位、高德定位、腾讯定位,三足鼎立一起为我所用!
- android 常用方法集合
- Android Studio快捷键大全
- 关于Android中各种尺寸的总结
- Android批量图片加载经典系列——使用LruCache、AsyncTask缓存并异步加载图片
- Android Studio之版本管理工具Git (图文教程)附连接到Git@OSC教程
- Android 得到当前已连接的wifi的信号强度
- Android批量图片加载经典系列——使用LruCache、AsyncTask缓存并异步加载图片
- Android-理解PendingIntent
- 给iOS开发者的Android开发建议
- Android开发详解之onTouch, onLongClick和onClick详解
- android 多屏幕适配 : 第一部分
- android的消息处理机制(图文+源码分析)—Looper/Handler/Message
- Android 问题解决方法(一)
- Android 4.0系统源码目录结构详解
- Android之android:launchMode