简体   繁体   中英

How to append shadow effect to imageview in android?

我想显示具有阴影效果的3D图像之类的imageview,请帮助我

Create one xml layout file under res -> drawable folder. Lets name it "image_shadow.xml", then copy below code to it.

<?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="@android:color/darker_gray" />
        <corners android:radius="0dp"/>
    </shape>
</item>
<item android:right="1dp"  android:bottom="2dp">
    <shape
        android:shape="rectangle">
        <solid android:color="@android:color/white"/>
        <corners android:radius="1dp"/>
    </shape>
</item>

</layer-list>

And then apply it within your ImageView as

android:background="@drawable/image_shadow

Hope it might help you.

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