11

Is it really to implement elevation of ImageView with png that contains transparent background? For example: i want to add elevation shadow to this pic:

enter image description here

Want make it like this:

enter image description here

rnrneverdies
  • 14,415
  • 9
  • 60
  • 92
Rahim Rahimov
  • 1,307
  • 14
  • 24

1 Answers1

1

In your XML add this:

android:elevation="2dp"    
android:background="@drawable/myrect"

In your Drawable folder add this drawable:

<!-- res/drawable/myrect.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="#42000000" />
    <corners android:radius="5dp" />
</shape>

See here for more info: http://developer.android.com/training/material/shadows-clipping.html

Chris Stillwell
  • 9,821
  • 9
  • 70
  • 73