Add shadow on right and bottom side of the layout

心已入冬 提交于 2019-12-03 05:36:30

I think this may solve your problem

 <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape>
                <padding android:bottom="2dp" android:left="0dp" android:right="2dp"
                         android:top="0dp"/>
                <solid android:color="#00CCCCCC"/>
            </shape>
        </item>
        <item>
            <shape>
                <padding android:bottom="2dp" android:left="0dp" android:right="2dp"
                         android:top="0dp"/>
                <solid android:color="#10CCCCCC"/>
            </shape>
        </item>
        <item>
            <shape>
                <padding android:bottom="2dp" android:left="0dp" android:right="2dp"
                         android:top="0dp"/>
                <solid android:color="#20CCCCCC"/>
            </shape>
        </item>
        <item>
            <shape>
                <padding android:bottom="2dp" android:left="0dp" android:right="2dp"
                         android:top="0dp"/>
                <solid android:color="#30CCCCCC"/>
            </shape>
        </item>
        <item>
            <shape>
                <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp"/>
                <solid android:color="#50CCCCCC"/>
            </shape>
        </item>

        <!-- Background -->
        <item>
            <shape>
                <solid android:color="@color/white"/>
                <corners android:radius="3dp"/>
            </shape>
        </item>
    </layer-list>

Then apply it to an XML layout as a background LinearLayout android:background="@drawable/drawable_name"

Prabhuraj

This is what I referred and it worked.

** 1.Add a plain LinearLayout with grey color, over which add your actual layout, with margin at bottom and right equal to 1 or 2 dp

2.Have a 9-patch image with a shadow and set it as the background to your Linear layout**

Other solutions here

Vibhu Vikram Singh

Just put android:hardwareAccelerated="true" into your Manifest Application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!