Rethinavel
Rethinavel

Reputation: 3952

Scrolling behaviour not working when toolbar is added at the bottom of the layout in Android

I have to add a toolbar at the bottom of the screen as per the design. The app:layout_scrollFlags="scroll|enterAlways" was working fine if i remove the relative layout inside the coordinator.

But i am unable to set the toolbar at the bottom of the screen without this relative layout!

How can i manage to get bottom toolbar and Top toolbar hide functionality by changing the following layout?

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="bottom"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />


            <android.support.design.widget.TabLayout
                android:id="@+id/tabLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/toolbar"
                android:background="@color/tab_color" />


        </android.support.design.widget.AppBarLayout>

        <include
            layout="@layout/inc_bottom_toolbar_with_menu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" />

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/bottomToolBar"
            android:layout_below="@id/appBarLayout"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />


    </RelativeLayout>

</android.support.design.widget.CoordinatorLayout>

PS : I had removed the image as my TL insisted to do so..

Upvotes: 1

Views: 696

Answers (1)

Anoop M Maddasseri
Anoop M Maddasseri

Reputation: 10569

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout>
      -----------------------
</android.support.design.widget.CoordinatorLayout>

<!-- bottom contents here --->

</RelativeLayout>

Upvotes: 1

Related Questions