Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout one side curve shape in android

I wanna to create Layout like this

enter image description here

And i achived this My problem is i don't know how to get curve shape in layout please help me.

enter image description here

Here is my code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activity.HomeActivity">

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="@color/sky">

    </RelativeLayout>


    <ImageView
        android:id="@+id/image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignBottom="@id/relativeLayout1"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="-30dp"
        android:src="@mipmap/ic_launcher" />


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/relativeLayout1">

    </RelativeLayout>
</RelativeLayout>
like image 325
Arpit Patel Avatar asked Dec 02 '16 12:12

Arpit Patel


People also ask

How do you make a rounded rectangle on Android?

Use CardView for Round Rectangle. CardView give more functionality like cardCornerRadius, cardBackgroundColor, cardElevation & many more. CardView make UI more suitable then Custom Round Rectangle drawable.

What is shape explain in detail in Android?

What is shape explain in detail in android? The shape is the XML Element which is defined in XML. and must be the root element. The file location is : res/drawable/your_shape.xml. The filename is used as the resource ID.25-Aug-2016.


2 Answers

i guess its too late, but it'll help others.


 <?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="@color/colorSignInText"/>
                    </shape>
                </item>
                <item
                        android:top="100dp"
                        android:bottom="0dp"
                        android:left="-70dp"
                        android:right="-70dp">

                    <shape xmlns:android="http://schemas.android.com/apk/res/android"
                           android:innerRadius="50dp"
                           android:shape="rectangle"
                           android:useLevel="true">

                        <solid android:color="@android:color/white"/>
                        <corners

                                android:bottomLeftRadius="0dp"
                                android:topLeftRadius="260dp"
                                android:topRightRadius="260dp"/>

                    </shape>
                </item>
            </layer-list>

Here take a look at the output:

Here take a look

like image 181
Haider Saleem Avatar answered Oct 07 '22 12:10

Haider Saleem


Check out this library over here: https://github.com/developer-shivam/Crescento You can use this effect as is OR you can have a peek into source code and see the implementation for yourself!

like image 36
Abhi Avatar answered Oct 07 '22 11:10

Abhi