Search code examples
androidxmlbox-shadow

Android: box shadow and border radius layout


I want box shadow and radius like below image, but in android box shadow not work

enter image description here

How can i use xml for this problem ?


Solution

  • for corner you have to use drawable like below:

    <shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >
    
    <!-- view border color and width -->
    <stroke
        android:width="1dip"
        android:color="#a4a2a2" >
    </stroke>
    
    <corners android:radius="180px">
    
    </corners>
    <!-- Here is the corner radius -->
    

    and about shadow

    i think you mean android:elevation="8dp"

    <Yourbox
    android:width="match_parent"
    android:height="match_parent"
    ....
    android:elevation="8dp"
    android:layout_gravity="center"
    ..
    />