Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Layout with Rounded drop shadow

Tags:

android

shape

I want shape in the background of the layout like given below picture. I have tried something , Which is given below.

borders.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--Layer 0-->
<!--Layer 1-->
<!--Layer 2-->
<!--Layer 3-->
<!--Layer 4 (content background)-->

    <!-- dropshadow -->
    <item>
        <shape>
            <solid android:color="#10CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#20CCCCCC" />
           <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#40CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#50CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#60CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <!-- content background -->
    <item>
        <shape>
            <solid android:color="#ffffff" />
        </shape>
    </item>
</layer-list>

And layout set as

android:background="@drawable/borders"

Through this implementation, I am getting like this

enter image description here

How can I get the drop shadow with rounded corners like below image?

enter image description here

like image 658
Mayur Raval Avatar asked Jun 12 '14 08:06

Mayur Raval


People also ask

How do I round corners in Android?

xml file and add an attribute to that TextView, for which you want to add rounded corners. The attribute is android: background=”@drawable/rounded_corner_view”.


1 Answers

you should add "corners" to the shape:

 <?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<solid android:color="#ffffffff"/>    

<stroke android:width="3dp"
        android:color="#ff000000"
        />

<padding android:left="1dp"
         android:top="1dp"
         android:right="1dp"
         android:bottom="1dp"
         /> 

<corners android:radius="7dp"/> 

like image 94
baronS Avatar answered Sep 20 '22 13:09

baronS