How do i make the relative layout look like the image
Asked
Active
Viewed 1.6k times
3 Answers
19
There are two ways to create shadow:
If sdk version is lower than 5.0...
A. You can also use android drawable image
android:background="@android:drawable/dialog_holo_light_frame"
B. Use below
shadow_round.xml
to make a drawable background for shadow of view.android:background="@drawable/shadow_round
<!-- Drop Shadow Stack --> <item> <shape> <padding android:top="1dp" android:right="1dp" android:bottom="2dp" android:left="1dp" /> <corners android:radius="10dp" /> <solid android:color="#00CCCCCC" /> </shape> </item> <item> <shape> <padding android:top="1dp" android:right="1dp" android:bottom="2dp" android:left="1dp" /> <corners android:radius="10dp" /> <solid android:color="#10CCCCCC" /> </shape> </item> <item> <shape> <padding android:top="1dp" android:right="1dp" android:bottom="2dp" android:left="1dp" /> <corners android:radius="10dp" /> <solid android:color="#20CCCCCC" /> </shape> </item> <item> <shape> <padding android:top="1dp" android:right="1dp" android:bottom="2dp" android:left="1dp" /> <corners android:radius="10dp" /> <solid android:color="#30CCCCCC" /> </shape> </item> <item> <shape> <padding android:top="1dp" android:right="1dp" android:bottom="2dp" android:left="1dp" /> <corners android:radius="10dp" /> <solid android:color="#50CCCCCC" /> </shape> </item> <!-- Background --> <item> <shape> <solid android:color="#ffffff" /> <corners android:radius="10dp" /> </shape> </item>
If you are using SDK 5.0 or greater then use the view's elevation property.
android:elevation="2dp"
-
Using A: This results in a weird flicker every couple of seconds, at least on 5.1 devices. The flicker goes away if you copy the resources from the SDK directly in to your app's res dir. No idea why. – Aug 27 '15 at 14:21
-
We've found that B is hideously slow on older, down version Android phones. – Kinetic Apr 05 '16 at 13:13
4
simple add elevation property in your relative layout. or create xml in drowable folder and call as a background
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ddd" />
<stroke
android:width="5dp"
android:color="#b8b9b9" />
<corners
android:radius="3dp" />
</shape>

sushant singh
- 696
- 1
- 8
- 18
0
Try this code:- radius.xml
:- this xml add in drawable folder in and relative layout in background in set
android:background="@drawable/radius"
<shape android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<stroke android:width="2dp" android:color="#b8b9b9"/>
<corners android:bottomLeftRadius="3dp" android:bottomRightRadius="3dp" android:topLeftRadius="3dp" android:topRightRadius="3dp"/>
</shape>

Abhishek Kumar
- 165
- 1
- 17

cyberlobe
- 1,783
- 1
- 18
- 30