如果你想在XML文件中設置
透明效果
android:background="#00000000"
半透明效果
android:background="#e0000000"
如果你想在java代碼中動態設置
透明
view.setAlpha(1.0f);
半透明
view.setAlpha(0.5f);
設置TextView,設置背景半透明,文字不透明
TextView textView = (TextView)findViewById(R.id.textView);//找到你要設透明背景的layout的id
textView.getBackground().setAlpha(100);//0~255透明度值
背景圖片透明度
ImageView imageView= findViewById(R.id.imageView);//找到你想要設置透明背景的layou的id
imageView.getBackground().setAlpha(100);//0--255爲透明度值