I have a toolbar which I would like to behaves as material design specifications. In this way, I wrapped it in a AppBarLayout
. The problem is that the RecyclerView
is a child of a ViewPager
:
<android.support.design.widget.CoordinatorLayout
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:orientation="vertical"
tools:context=".ui.home.HomeActivity">
<ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/activity_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<com.rocket.android.views.SlidingTabLayout
android:id="@+id/pager_indicator"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/tab_and_nav_bar"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
How can I attach the AppBarLayout
to react to an arbitrary RecyclerView
which is not his sibling?
Here is how I solved it.
This brings a padding-related problem for the pages in the
ViewPager
. I solved this one adding a padding which size is the same height of the tab layout. It works. Not the best solution though.