0

How to make my bottom navigation stay at the bottom with the root parent being Scrollview? The bottom navigation did not stay at the bottom when I change my root parent which is Scrollview.

<ScrollView 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:fillViewport="true"
    tools:context=".ManageActivity">

    <LinearLayout ... >

        <androidx.cardview.widget.CardView ...>

 <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/btm_nav"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@color/purple"
            android:clipToPadding="false"
            app:itemIconTint="@color/bottom_nav_color"
            app:itemTextColor="@color/bottom_nav_color"
            app:menu="@menu/bottom_nav" />

    </LinearLayout>


</ScrollView>

lylyn
  • 13
  • 1
  • 6
  • Change LinearLayout to RelativeLayout, and set it's height to match_parent. Property layout_alignParentBottom doesn't work in LinearLayout as parent layout. – Ban Markovic Oct 10 '19 at 08:43

1 Answers1

0

Try like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/navigation" >
        <!--Other Stuff here-->
    </ScrollView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/purple"
        android:clipToPadding="false"
        app:itemIconTint="@color/bottom_nav_color"
        app:itemTextColor="@color/bottom_nav_color"
        app:menu="@menu/bottom_nav" />

</RelativeLayout>
Md. Asaduzzaman
  • 14,963
  • 2
  • 34
  • 46