Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 584
bcsta Avatar asked Oct 21 '25 06:10

bcsta


1 Answers

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

like image 121
bcsta Avatar answered Oct 24 '25 20:10

bcsta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!