How to make relative layout with box shadow

enter image description here

How to make a relative layout look like an image

+6
source share
2 answers

For the shadow shadow, you have two ways:

  • If sdk version is lower than 5.0,

a. You can also use a picture designed for Android.

android:background="@android:drawable/dialog_holo_light_frame"

B. For shadow, use shadow_round.xml below.

 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 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> </layer-list> 

And use as background for viewing.

Android: background = "@ hood / shadow_round"

  1. If you are using 5.0, use the Elevation property.

    Android: Height = "2dp"

I hope this works for you.

+13
source

Try this code: - radius.xml

: - this xml adds to the drop-down folder and the relative layout in the background in the 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> 
0
source

Source: https://habr.com/ru/post/984222/


All Articles