android 如何把一个 RelativeLayout或ImageView背景设为透明?

如题所述

第1个回答  推荐于2019-08-31
设置背景为透明
1、设置背景为透明
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"

android:background="@android:color/transparent"/><!--#00000000-->也可以设置颜色值,前两位为透明度
2、设置背景透明度
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"/>
相应的也可以在java代码中设置透明本回答被网友采纳
第2个回答  2020-03-23
设置背景为透明
1、设置背景为透明
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"/><!--#00000000-->也可以设置颜色值,前两位为透明度
2、设置背景透明度
<ImageView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"/>
相应的也可以在java代码中设置透明