简体   繁体   中英

How to add a drop shadow to a Rectangular Shape in Android

I am developing an Android App in which I need to use a Rectangular shape which should have a drop_shadow. I have designed a rectangular shape but somehow i am not able to add a drop shadow to it on (right and left sides). PS: this rectangular shape is added as a background attribute.

If this type of Question is already been answered then please provide the links here.

THANK YOU IN ADVANCE!!!!

在此处输入图片说明

Code:

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff" />
    <stroke
        android:width="1dp"
        android:color="#000000" />
    <corners
        android:radius="10dp"   >
    </corners>

</shape>

Try this:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list    
        xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#CABBBBBB"/>
            <corners android:radius="2dp" />
        </shape>
    </item>

    <item
        android:left="0dp"
        android:right="1dp"
        android:top="0dp"
        android:bottom="2dp">

        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="1dp" />
        </shape>
   </item>
</layer-list>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM