简体   繁体   中英

How to make image view with rounded edge at bottom with shadow

I want to make my ImageView curved at the bottom with shadow effect.

Similar to this image

在此处输入图像描述

But I don't have any idea about how to do this.

Whenever I search on Google or StackOverflow it shows me results related to curved corners but I want curved edge at bottom.

you can make shape use layer-list

for example,

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:left="-150dp"
        android:right="-150dp"
        android:top="-200dp">
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="oval">
            <solid android:color="#C72C2F" />
        </shape>
    </item>
</layer-list>

it show like this.

在此处输入图像描述

And then use this in background,

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        app:layout_constraintTop_toTopOf="parent"
        android:background="@drawable/round"
        android:elevation="30dp"
        android:layout_width="match_parent"
        android:layout_height="700dp"/>

</androidx.constraintlayout.widget.ConstraintLayout>

it make like this.

在此处输入图像描述

Also for make shadow effect, I use android:elevation it make shadow, and if you increase value, it can make more depth.

And obviously add image view for show images. I believe you can do this.

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