Search code examples
androidandroid-imageview

Android: ImageView background does not change


I have the following ImageView inside a ContraintLayout:

<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" />

The app_logo is a nodpi PNG with a transparent background. I have checked it, it's transparent.

No matter which background-related property I set, I always get a white squircle behind the image. (A shape may come from the One UI, I guess.)

What am I missing? I have several ImageViews in my app, and every one of them has the background I need, except this one. It's driving me crazy.


Solution

  • Have you tried getting rid of the android:src="@mipmap/app_icon" line? You probably shouldn't be referencing mipmaps in layout XML. And, besides, you already have srcCompat there pointing to another image.