2

enter image description here

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.

user3530687
  • 183
  • 2
  • 8
  • 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 :) – user3530687 Feb 16 '16 at 10:51

2 Answers2

3

Give some elevation to your linear layout like

android:elevation="10dp"

Put this in your xml

Adnan Amjad
  • 2,423
  • 1
  • 18
  • 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
  • 4,413
  • 4
  • 41
  • 59