android编程中 设置控件透明效果的常见三种方法

来源:互联网 发布:单片机最小系统图 编辑:程序博客网 时间:2024/06/10 20:35

android编程中 设置控件透明效果的常见三种方法

第一种:

android系统的透明效果:

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

如:

<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" /> 


第二种:

ARGB来控制:

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


第三种:

设置alpha

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

v.getBackground().setAlpha(100);//透明度0~255透明度值 ,值越小越透明

原创粉丝点击