androidxmlshadows

Android Shadow Design


Hi I made a layout on powerpoint and I implemented it on android with xml but they are not same (shadow things). Here is the images difference (left side android right side what I want to create):

this is what I want

this is what I did

I use xml for android layout:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Bottom Shadow -->
<item
    android:left="2.0dp"
    android:right="2.0dp">
    <shape android:shape="rectangle" >
        <corners android:radius="2dp" />

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

        <gradient
            android:angle="270"
            android:centerColor="#FF222222"
            android:centerX="0.15"
            android:endColor="#55000000"
            android:startColor="#FF000000" >
        </gradient>
    </shape>
</item>
<!-- White Top color -->
<item>
    <shape android:shape="rectangle" >
        <solid android:color="#E6E0EC" />
    </shape>
</item>

How can I same shadows with xml thank you.


Solution

  • Try this one:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="rectangle">
                <gradient android:angle="90"
                    android:endColor="#E0E0E0" android:startColor="#ccc" />
                <corners android:radius="4dp" />
            </shape>
        </item>
    
        <item
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp"
            android:bottom="1.5dp">
            <shape android:shape="rectangle">
                <solid android:color="#E6E0EC"/>
                <corners android:radius="4dp" />
            </shape>
        </item>
    </layer-list>