longwalker longwalker - 7 months ago 116
Android Question

Android View shadow

I searched around, and I could not find a proper way to do this. I want to have the following shadow effects on my views:
enter image description here

enter image description here

To be honest, I do not know if this second one is done by applying shadow effect. Any ideas?


I know this question has already been answered but I want you to know that I found a drawable on Android Studio that is very similar to the pics you have in the question: Take a look at this:


It looks like this:

enter image description here

Hope it will be helpful


The option above is for the older versions of Android Studio so you may not find it. For newer versions:


Moreover, if you want to have your own custom shape, I suggest to use a drawing software like Photoshop and draw it.

enter image description here

Don't forget to save it as .9.png file (example: my_background.9.png)

Read the documentation: Draw 9-patch

Edit 2

An even better and less hard working solution is to use a CardView and set app:cardPreventCornerOverlap="false" to prevent views to overlap the borders:


    <!-- your layout stuff here -->


Also make sure to have included the latest version in the build.gradle, current is

compile 'com.android.support:cardview-v7:23.1.1'