Draw Rectangle View with curve bottom In Android Draw Rectangle View with curve bottom In Android android android

Draw Rectangle View with curve bottom In Android


Just play with the oval item values to get the desired output.

curve_toolbar_bg.xml

<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android">    <item>        <shape android:shape="rectangle"/>    </item>    <item        android:bottom="0dp"        android:left="-100dp"        android:right="-100dp"        android:top="-80dp">        <shape android:shape="oval">            <solid android:color="@color/colorPrimary" />        </shape>    </item></layer-list>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.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:id="@+id/container"    android:layout_width="match_parent"    android:layout_height="match_parent">    <android.support.v7.widget.Toolbar        android:id="@+id/toolbar"        android:layout_width="0dp"        android:layout_height="?android:attr/actionBarSize"        android:background="@drawable/curve_toolbar_bg"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toTopOf="parent"        app:layout_constraintVertical_bias="0.0">    </android.support.v7.widget.Toolbar></android.support.constraint.ConstraintLayout>

Curve shape toolbar


This is what I did to achieve curved status bar on my android application. This created a toolbar that can be over other views so when you scroll views goes under the toolbar.

First I hid the original Toolbar from activity by creating a no title theme and selecting that theme from manifest. Then I created a Titlebar of my own and then by playing with margins and paddings I achieved desired result.

statusbar

sytles.xml:

    <style name="Notitle.Theme" parent="Theme.AppCompat.NoActionBar">    <item name="android:windowNoTitle">true</item></style>

AndroidManifest.xml

<activity        android:name=".MainActivity"        android:theme="@style/AppTheme.NoActionBar"/>

arch.xml:

<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item>    <shape android:shape="rectangle"/></item><item    android:bottom="0dp"    android:left="-100dp"    android:right="-100dp"    android:top="-80dp">    <shape android:shape="oval">        <gradient            android:startColor="#2629fb"            android:endColor= "#2699FB"            android:angle="90" />    </shape></item></layer-list>

mainActivity.xml:

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:id="@+id/linearLayout"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="#27292c"><androidx.appcompat.widget.Toolbar    android:id="@+id/toolbar"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:minHeight="?attr/actionBarSize"    app:layout_constraintEnd_toEndOf="parent"    app:layout_constraintStart_toStartOf="parent"    app:layout_constraintTop_toTopOf="parent"    android:contentInsetLeft="0dp"    android:contentInsetStart="0dp"    app:contentInsetLeft="0dp"    app:contentInsetStart="0dp"    android:contentInsetRight="0dp"    android:contentInsetEnd="0dp"    app:contentInsetRight="0dp"    app:contentInsetEnd="0dp"    android:layout_marginBottom="-50dp"    android:elevation="5dp"    android:background="@drawable/arch">    <TextView        android:id="@+id/headerWidgetTitle"        android:text="Title"        android:gravity="center"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:textSize="24sp"        android:paddingTop="10dp"        android:textColor="#FFFFFF"        android:paddingBottom="20dp"/></androidx.appcompat.widget.Toolbar>    <ScrollView        android:layout_width="match_parent"        android:layout_height="match_parent">        <LinearLayout            android:id="@+id/scrollLinearLayout"            android:layout_height="wrap_content"            android:layout_width="match_parent"            android:orientation="vertical"            android:elevation="0dp"            android:paddingTop="50dp"            android:clipToPadding="false">            <!-- Your Views -->              </LinearLayout>    </ScrollView>