3

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

Similar to this image

enter image description here

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.

Amol Barge
  • 61
  • 1
  • 9

1 Answers1

0

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.

enter image description here

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.

enter image description here

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.

S T
  • 1,068
  • 2
  • 8
  • 16
  • it's perfect but how to add an image inside this shape instead of just red color image is dynamically added to the view, not from resources. this is what I have tried https://photos.app.goo.gl/QHbosfA1G5iKWg5q6 – Amol Barge Jul 03 '20 at 08:15
  • did you use image library? example `Glide`? – S T Jul 03 '20 at 08:17
  • then you have to make image like transparent hole. it means red part should transparent and make out part is white. And set images in this. like ths https://stackoverflow.com/a/11227247/10778405 – S T Jul 03 '20 at 09:13
  • I think designer can make it – S T Jul 03 '20 at 09:22