I want to apply shadow to the ImageView
. When I'm applying shadow to a TextView
I'm getting it but same it's not getting to ImageView
. How can I solve this problem?
We can also use CardView which provides a rounded corner background and shadow. To use that you need to add the v7 CardView library as a dependency to the project in the build.gradle like below.
dependencies {
compile 'com.android.support:cardview-v7:23.0.1'
-------
}
Note: Change
23.0.1
in the above line with the respected version.
So I surrounded the ImageView
with CardView
to make shadow like below.
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="@android:color/white">
<ImageView
android:id="@+id/dish_image"
android:layout_width="match_parent"
android:layout_height="120dp"
android:adjustViewBounds="true" />
</android.support.v7.widget.CardView>
It'll add a shadow around the image.
Note: I don't know whether it is a good workaround. I am a beginner. I tried to implement the
CardView
which gives an idea to implement the same for this. If it is not good please update me with the reason.