Ritik
Ritik

Reputation: 132

How to Make Custom Shaped Layout in Android

I'm making a bottom navigation bar, of custom shape Like this =>

BottomToolbar

So I tried using LinearLayout with a FAB on it, as I dont know much about custom shapes, but my idea not working as, when I scroll my webView bottombar hides, but fab doesn't. Anyways this is a bad method.

So, What I want is to make a custom shaped bottombar, please help me make it, or just simple guiding would be helpful,

Thank you so much :)

Upvotes: 1

Views: 2809

Answers (1)

Rakshit Nawani
Rakshit Nawani

Reputation: 2604

enter image description hereCreate a drawable with the below fields

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="4dp"
        android:left="20dp"
        android:right="20dp"
        android:top="15dp">
        <shape android:shape="rectangle">
            <solid android:color="#ED7D31" /> //Color of youe choice
        </shape>
    </item>

    <item
        android:width="50dp"
        android:height="50dp"
        android:gravity="top|center">
        <shape android:shape="oval">
            <solid android:color="#ED7D31" />

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

and in the XML file add it as a background like below

<TextView
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:elevation="4dp"
    android:background="@drawable/list" /> //Your drawable name here

Upvotes: 2

Related Questions