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?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You can create a layer list drawable and put your two items (drawables) in it for an image and your shadow.
Your shadow item's position & content might change according to where you want to apply the shadow (top, left, right, both right & left etc) and style of your shadow.
This is taken from Romain Guy's presentation at Devoxx, pdf found here.
Hope this helps.
NOTES
Don't forget for Honeycomb and above you need to invoke
setLayerType(LAYER_TYPE_SOFTWARE, mShadow)
, otherwise you will not see your shadow! (@Dmitriy_Boichenko)SetShadowLayer
does not work with hardware acceleration unfortunately so it greatly reduces performances (@Matt Wear)Answer Taken from Here
For Api greater than 21. You can try in xml in imageview or Button : Read here at developer site
Create a file shadow_rect.xml
And the use this as android:background="@drawable/shadow_rect within your Imageview.
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.
So I surrounded the
ImageView
withCardView
to make shadow like below.It'll add a shadow around the image.