您的位置:首页 > 移动开发 > Android开发

android 设置透明效果

2016-05-31 14:46 309 查看
转载自:http://blog.csdn.net/sy_shu/article/details/6993350

设置透明效果 大概有三种

1、用android系统的透明效果

Java代码

android:background="@android:color/transparent" 

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="@android:color/transparent"

  android:text="@+id/Button01"

  android:id="@+id/Button01"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:textColor="#ffffff" />

2、用ARGB来控制

Java代码

半透明<Button android:background="#e0000000" />  

透明<Button android:background="#00000000" /> 

半透明<Button android:background="#e0000000" />

透明<Button android:background="#00000000" />

3、设置alpha

Java代码

View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id  

v.getBackground().setAlpha(100);//透明度0~255透明度值 ,值越小越透明
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: