Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android BottomAppBar have extra left padding

I am using BottomAppBar in my app but it have a extra left padding. how to remove this padding? my xml code is:

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:backgroundTint="@color/spark_secondary_color"
        >

        <LinearLayout
            android:id="@+id/bottom_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:background="@color/white"
            android:orientation="horizontal"
            >

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@android:drawable/ic_menu_search"
                    android:background="?attr/selectableItemBackground"
                    />
            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center">

                <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@android:drawable/ic_menu_send"
                    android:background="?attr/selectableItemBackground"
                    />

            </LinearLayout>

        </LinearLayout>

    </com.google.android.material.bottomappbar.BottomAppBar>


</androidx.coordinatorlayout.widget.CoordinatorLayout>

and result is:

enter image description here

like image 905
Hadi Ahmadi Avatar asked Sep 11 '19 06:09

Hadi Ahmadi


1 Answers

adding app:contentInsetStart="0dp" to BottomAppBar solved my problem.

<com.google.android.material.bottomappbar.BottomAppBar
    android:id="@+id/bottom_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"
    app:contentInsetRight="0dp"
    app:contentInsetEnd="0dp"
    app:elevation="8dp"
    app:hideOnScroll="true"
    >
     ...

   </com.google.android.material.bottomappbar.BottomAppBar>
like image 194
Hadi Ahmadi Avatar answered Oct 27 '22 18:10

Hadi Ahmadi