0

I have my main xml set up as such:

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

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

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:scrollbars="horizontal"
        android:layout_below="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary" />

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

<android.support.v4.view.ViewPager
    android:id="@+id/tab_view_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<!-- Your Scrollable View -->
<!--<include layout="@layout/cardviews"/>-->

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_note_add_white_48dp"
    android:layout_marginBottom="20dp"
    android:layout_marginRight="20dp"
    android:layout_gravity="bottom|right"
    app:fabSize="normal" />

In the tutorial that I was following, they implemented a scrolling list of card views which pushed up the tab layout when the list was scrolled.

However, here I have a view pager instead of a list of card views which scrolls horizontally. Within the pages of the view pager, I have a list fragment which contains a vertical list.

Yet, when I scroll this vertical list within the view pager, the tab layout is not pushed up!

How do I get this nested listfragment to interact with the tab layout.

wayway
  • 6,439
  • 5
  • 44
  • 84

1 Answers1

3

The AppBar only behaves that way if you use a NestedScrollView or a RecyclerView. Both these classes implement NestedScrollingChild, and my guess is that your ListFragment does not use either of these classes for the list functionality.

Lamorak
  • 10,190
  • 8
  • 44
  • 55
Chris Thoma
  • 499
  • 2
  • 8
  • So if I implement nested scrolling child with my list fragment it will work? – wayway Aug 31 '15 at 02:08
  • It looks like it should based on your XML, but I would switch to a recyclerview if you can for simplicity sake. – Chris Thoma Aug 31 '15 at 02:10
  • Could you please point me to some resources that I could look into? Thank you! – wayway Aug 31 '15 at 02:11
  • 1
    @WayWay try this maybe? http://stackoverflow.com/questions/30696611/design-lib-coordinatorlayout-collapsingtoolbarlayout-with-gridview-listview – Chris Thoma Aug 31 '15 at 02:15