Android ImageView中图像后面的黑色背景
看起来很傻,但我试过使用ImageButton,图像视图,但圆形图像后面的黑色正方形不起作用。我使用png图像,并希望透明的背景 我已经附上了预期的输出,在android和真实设备的布局视图,但看起来非常不同,似乎没有任何工作 预期结果 实际结果 可绘制资源图像 编辑代码XML布局。重置其他视图即可 版面图像Android ImageView中图像后面的黑色背景,android,android-imageview,android-resources,Android,Android Imageview,Android Resources,看起来很傻,但我试过使用ImageButton,图像视图,但圆形图像后面的黑色正方形不起作用。我使用png图像,并希望透明的背景 我已经附上了预期的输出,在android和真实设备的布局视图,但看起来非常不同,似乎没有任何工作 预期结果 实际结果 可绘制资源图像 编辑代码XML布局。重置其他视图即可 版面图像 如果不需要黑色背景,请使用此选项,只需从布局中删除背景即可 <android.support.v7.widget.AppCompatImageView android
如果不需要黑色背景,请使用此选项,只需从布局中删除背景即可
<android.support.v7.widget.AppCompatImageView
android:id="@+id/btn_key"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:src="@drawable/img_key"
/>
我的图像也有同样的问题,我刚刚做的就是更改imageView的背景并使其透明
<ImageView
android:id="@+id/iv_dashboard"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
android:background="@android:color/transparent"
android:src="@drawable/bg_dashboard"
app:layout_constraintBottom_toTopOf="@+id/guide_horizontal_30"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
布局无任何更改。仍然有黑色背景检查@drawable/bg_dashboard,您是否使用黑色背景?不,这是一张图片,不是黑色的,我用黑色重叠了它。在约束布局中使用白色背景,结果如何?让我们来看看。父视图的背景是什么,它有您的图像视图
?你能发布完整的/相关的版面吗?检查编辑的问题我不明白你发布的图片是什么样的屏幕截图或其他东西,搜索图标后面没有黑色背景。图片来自xml版面。是的,我知道图像后面没有黑色背景,但它仍在显示,这就是我感到困惑的原因好吧,那么你的意思是说它在布局预览中不显示黑色背景,但在设备中显示?您也尝试过简单的ImageView吗?设备有暗模式吗?
<ImageView
android:id="@+id/iv_dashboard"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
android:background="@android:color/transparent"
android:src="@drawable/bg_dashboard"
app:layout_constraintBottom_toTopOf="@+id/guide_horizontal_30"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />