hello, This is my UI, i am trying to put shadow to Linear Layout, if you see there is shadow background of Linear layout, I have tried, took parent layout gave to it grey color and then gave white color to this linear layout, but it looks grey border, but as you see i don't want that way. This is shadow Please help.
Asked
Active
Viewed 1,528 times
2
-
Have you tried this: http://stackoverflow.com/questions/24095223/android-linearlayout-add-border-with-shadow-around-a-linearlayout – Rohit Sharma Feb 16 '16 at 10:24
-
[enter link description here](http://stackoverflow.com/questions/13005714/how-to-show-shadow-around-the-linearlayout-in-android) look at archie.bpgc answer – Bliss Feb 16 '16 at 10:36
-
@RohitSharma thank you, i have created 9-patch-image, it looks the same as i want :) – Aniket-Shinde Feb 16 '16 at 10:51
2 Answers
3
Give some elevation to your linear layout like
android:elevation="10dp"
Put this in your xml

Adnan Amjad
- 2,553
- 1
- 20
- 29
1
Why not to use CardView
?
You can wrap your LinearLayout
in CardView
and get the shadow effect from the CardView
. As far as I think, this is not possible with simple XML and you will have to use 9-Patch. Since you want this compatible with pre-lollipop, CardView
is the simplest way.
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
...
card_view:cardBackgroundColor="@android:color/white"
card_view:cardCornerRadius="4dp"
card_view:cardUseCompatPadding="true" />

Mangesh
- 5,491
- 5
- 48
- 71