Reputation: 12145
I want to add shadow around ImageView
I tried elevation
<ImageView
android:layout_margin="10dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:src="@drawable/ic_icon_compass"
android:elevation="2dp"
android:background="@drawable/ic_circle_white"
android:padding="10dp"
android:layout_width="40dp"
android:layout_height="40dp"/>
Layout Preview works fine
But on the device it looks like this
(shadow is cropped at the bottom)
Why does it happen?
Upvotes: 2
Views: 1790
Reputation: 11
instead of deciding the height and width in the xml , try to mention in the drawable and instead of using
android:src="@drawable/ic_icon_compass"
use
android:background="@drawable/ic_icon_compass"
Upvotes: 0
Reputation: 8853
It looks like parent view is clipping the shadow. Look for the parent that is clipping the shadow it might not be the immidiate parent. Add this to the parent view/s in the xml and check.
android:clipChildren="false"
Upvotes: 1