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
  • 15,243
  • 9
  • 65
  • 95
Rahim Rahimov
  • 1,347
  • 15
  • 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
  • 10,266
  • 10
  • 67
  • 77