【发布时间】:2020-08-27 10:38:20
【问题描述】:
我在 ContraintLayout 中有以下 ImageView:
<ImageView
android:id="@+id/app_logo"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:contentDescription="@string/app_name"
android:src="@mipmap/app_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/about"
app:srcCompat="@drawable/app_logo" />
app_logo 是具有透明背景的 nodpi PNG。我查过了,是透明的。
无论我设置哪个与背景相关的属性,我总是在图像后面得到一个白色的松鼠。 (我猜,形状可能来自 One UI。)
我错过了什么?我的应用程序中有几个 ImageView,每个都有我需要的背景,除了这个。快把我逼疯了。
【问题讨论】:
-
您是否尝试过摆脱
android:src="@mipmap/app_icon"行?您可能不应该在布局 XML 中引用 mipmap。此外,您已经有srcCompat指向另一张图片。 -
您能提供给我们您的图片吗?
-
@GavinWright 我已经把头撞到桌子上两天了。你救了我的理智。一开始我想使用应用程序图标,后来决定使用更详细的图标,但我不知道那条线是如何到达那里的,因为我总是使用
scrCompat。请发表您的评论作为答案,以便我接受!