1、用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" />
 
 
 2、用ARGB来控制
 
  Java代码 
 
 
半透明<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透明度值
 
 
 android 窗体透明的,黑暗度等的设置技巧
 
 
设置透明度(这是窗体本身的透明度,非背景)
    | 
    | 
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha=0.3f;
getWindow().setAttributes(lp); 
 
以上设置对dialog对话框同样有效
 
Activity的透明、半透明效果的设置transparent
 
res/values/styles.xml
 
 | 
 
res/values/color.xml
 
 | 
 
manifest.xml
 
 |  | 
 
java代码
 
 |  | 
 
配置结束。










