androidxmlandroid-layoutmaterial-components-androidandroid-bottomappbar

Why my appbottombar is taking my whole layout height


I am using this code in my xml layout I added my layout below and some images

 ......

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/notes_container_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

       .......
        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/add_note_fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/medium_margin"
            android:backgroundTint="@color/colorPrimary"
            app:layout_anchor="@id/bottomAppBar"
            app:srcCompat="@drawable/ic_add_black_24dp"
            tools:ignore="VectorDrawableCompat" />
        <com.google.android.material.bottomappbar.BottomAppBar
            android:id="@+id/bottomAppBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:backgroundTint="@color/colorPrimary"
            app:hideOnScroll="false"
            app:menu="@menu/appbar_menu"
            app:navigationIcon="@drawable/ic_menu" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

and the height of the BottomAppbar is taking my whole layout as shown in the image enter image description here

and it should look like this image enter image description here


Solution

  • The issue is not in the dimension of the BottomAppBar.
    Check your parent layout dimension or position:

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/notes_container_layout"
        android:layout_height="wrap_content"
    

    The BottomAppBar has the right height but the CoordinatorLayout uses android:layout_height="wrap_content".
    Change the height of the CoordinatorLayout or use android:layout_gravity="bottom" in your CoordinatorLayout.

    enter image description here