bcsta
bcsta

Reputation: 2327

android:elevation is not working on an imageView of a vector drawable

I have a simple ImageView of a trashcan which I imported as a vector asset. This is the XML

<ImageView
    android:id="@+id/trashcan"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="10dp"
    android:layout_marginBottom="8dp"
    android:elevation="10dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/ABtn"
    app:layout_constraintTop_toTopOf="parent"
    android:background="@drawable/ic_trashcan" />

Why is it that the shadow does not show even with elevation? I would like to avoid using a cardview container and use its shadow because otherwise I would have to enclose any kind of ImageView in a cardView just for that reason.

The above ImageView's parent is a ConstraintLayout.

Upvotes: 4

Views: 2730

Answers (1)

bcsta
bcsta

Reputation: 2327

Adding android:outlineProvider="paddedBounds" showed the elevation shadow. Does anyone know why?

Upvotes: 4

Related Questions