Android设置透明、半透明等效果
Java代码
android:background="@android:color/transparent"
Java代码
<Button android:background="@android:color/transparent"
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff" />
半透明<Button android:background="#e0000000" />
透明<Button android:background="#00000000" />
View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
1 |
WindowManager.LayoutParams lp=getWindow().getAttributes(); |
2 |
lp.alpha= 0 .3f; |
3 |
getWindow().setAttributes(lp); |
设置黑暗度
1 |
WindowManager.LayoutParams lp=getWindow().getAttributes(); |
2 |
lp.dimAmount= 0 .5f; |
3 |
getWindow().setAttributes(lp); |
4 |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
设置背景模糊
1 |
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, |
2 |
WindowManager.LayoutParams.FLAG_BLUR_BEHIND); |
1
2 3 4 5 6 7 8 9 10 11 12 |
<resources>
<style name="Transparent"> <item name="android:windowBackground"> @color/transparent_background </item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle"> @+android:style/Animation.Translucent </item> </style> </resources> |
1
2 3 4 5 6 7 |
<?xml version="1.0" encoding="utf-8"?>
<resources> <color name="transparent_background">#50000000</color> </resources> //注意: //color.xml的#5000000前两位是透明的效果参数从00--99(透明--不怎么透明), //后6位是颜色的设置 |
1
2 3 4 |
<activity
android:name=".TransparentActivity" android:theme="@style/Transparent"> </activity> |
1
2 3 4 5 |
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setTheme(R.style.Transparent); setContentView(R.layout.transparent); } |
Android设置透明、半透明等效果的更多相关文章
- android设置view透明度的效果
android设置view透明度的效果 推荐textView.setBackgroundColor(Color.TRANSPARENT); 第一种方法:在xml文件中设置背景颜色. andro ...
- android设置背景半透明效果
1.Button或者ImageButton的背景透明或者半透明 半透明:<Button android:background="#e0000000"···> 透明:&l ...
- 第三十九篇、NavBar动态隐藏、设置透明、毛玻璃效果
1.动态隐藏 - (void)viewDidLoad { [super viewDidLoad]; if ([self respondsToSelector:@selector(automatical ...
- Android课程---Android设置透明效果的三种方法(转)
1.使用Android系统自带的透明效果资源 <Button android:background="@android:color/transparent"/> ...
- Android设置透明状态
xml中: android:background="@android:color/transparent" 半透明: android:background="#e0000 ...
- android设置透明状态栏
先是半透明效果(两种方法): 第一种(简单): //直接将下面的代码放在activity中的setContentView(R.layout.activity_main);中之前就行了 if (Buil ...
- Android实现透明的颜色效果
android Button或者ImageButton背景透明状态设置 设置Button或ImageButton的背景为透明或者半透明 半透明< Button android:backgroun ...
- Android实现透明的颜色效果(zz)
android Button或者ImageButton背景透明状态设置 设置Button或ImageButton的背景为透明或者半透明 半透明< Button android:backgroun ...
- Android设置透明状态栏和透明导航栏
Android透明状态栏只有在4.4之后有. 在代码中加入下面几行代码即可实现
随机推荐
- HTML 编辑器
使用 Notepad 或 TextEdit 来编写 HTML 可以使用专业的 HTML 编辑器来编辑 HTML: Adobe Dreamweaver Microsoft Expression Web ...
- HTML5外包团队——技术分享:HTML5判断设备在线离线及监听网络状态变化例子
<!doctype html> <html> <head> <meta http-equiv="content-type" content ...
- 轻量级开源内存数据库SQLite性能测试
[IT168 专稿]SQLite是一款轻型的数据库,它占用资源非常的低,同时能够跟很多程序语言相结合,但是支持的SQL语句不会逊色于其他开源数据库.它的设计目标是嵌入式的,而且目前已经在很多嵌入式产品 ...
- (转)Lambda表达式详解
本文转载自:http://www.cnblogs.com/knowledgesea/p/3163725.html 前言 1.天真热,程序员活着不易,星期天,也要顶着火辣辣的太阳,总结这些东西. 2.夸 ...
- bzoj1536: [POI2005]Akc- Special Forces Manoeuvres
Description 在一次军事行动中有一批空降兵要降落在沙漠中拆除炸弹. 空降兵按照预定的顺序跳伞并降落到指定的位置.一旦降落他们便呆在原地不动了. 每个空降兵都有一个生存半径. 如果炸弹与他的距 ...
- Python 通过print将数据保存到文件中
1. Print them to screen man = [] other = [] try: data = open('sketch.txt') for each_line in data: tr ...
- Linux命令之WC
$ wc story.txt39 237 1901 story.txt● Use -l for only line count● Use -w for only word count● Use -c ...
- QT5中的信号与槽与C++ 11的function的配合
最近将公司的界面开发库从WX转换到了QT,有了信号和槽,原本我们在使用WX的时候,为了使用信号,我们是使用BOOST的signal2库,到了QT有了信号槽,这个就没什么必要了 但是前段时间使用QT发现 ...
- usaco 2010年3月银组题解
usaco银组解题报告 一.石子游戏如果把‘O’当作0,‘X’当做1,则N个洞的每一种状态都可以看做是一个N位二进制数.于是,这个问题就变成了求环绕的N位格雷码.幸运的是,这个结构很容易就能够用一个简 ...
- Sqlserver 树形查询
WITH tree AS(SELECT dwpid, dwid,1 AS x2level,dwmc,/*CAST(dwmc AS NVARCHAR(max)) x2name,*/CAST(+dwid ...