让一个View透明
来源:互联网 发布:中国电视网络电视台 编辑:程序博客网 时间:2024/05/01 13:39
继承自View的类都有一个android:background XML属性,按照文档的说法,这个属性不只指定背景颜色,还可指定背景图片。背景图片好说,直接用"@drawable/img"指定一幅图片即可,而且支持透明PNG,这样就很足够了。对于单纯颜色,可以使用#rgb", "#argb", "#rrggbb", 或者 "#aarrggbb"等样式的数值,其中的a即alpha、透明度,比如说#ff000000表示不透明的黑色。指定控件的android:background属性为"@android:color/transparent"可实现背景的透明。
再者,有些控件的相关方法可以解决,像是ImageView的setAlpha()什么的.
例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/wallpaper"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#86222222"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:background="@drawable/chat"
android:id="@+id/bt_chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:background="@drawable/calendar"
android:id="@+id/bt_calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
- 让一个View透明
- 让透明view上的控件不透明
- android中如何让一个Activity透明
- 如何让一个iframe 背景透明?
- 让一个view变圆
- iOS开发如何让透明View里的对象不透明
- 如何让view只响应一个按钮
- 如何让view只响应一个按钮
- 如何让一个IFRAME调用页面的背景为透明?
- 如何让一个IFRAME调用页面的背景为透明
- ios 如何让一个view居中另一个view
- 让treeview背景透明
- 让窗口透明起来
- 如何让iframe透明
- 让Activity透明
- 如何让Activity透明
- 如何让Activity透明
- 如何让Activity透明
- 【定期发布】全国大白菜批发价格走势(单位:元/公斤) (截止至2010-10-14)
- 编写高效PHP代码总结
- 明晰C++内存分配的五种方法的区别
- 函数指针与回调函数(转载)
- PHP实例说明编写PHP代码的5个好习惯
- 让一个View透明
- 转八款Js框架介绍及比较
- Linux权限
- PHP教程:挖掘细节提升网站性能
- 【定期发布】全国土豆批发价格走势(单位:元/公斤) (截止至2010-10-14)
- IDFTP删除整个目录
- poj1066
- PE文件格式-1(PE文件与WINNT.H文件结构对照)
- 数据库启动过程