I am trying to do something like this:

I currently have the above layout without an embedded header. All I need to do is figure out how to add a title.
Here is the title layout that I want to put above the tabs:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/header" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_horizontal" android:background="@color/green"> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="match_parent" > <ImageView android:layout_width="50dp" android:layout_height="50dp" android:background="@drawable/ic_image" android:adjustViewBounds="true" android:scaleType="centerCrop" android:layout_gravity="center_vertical" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hey!" android:textColor="@color/white" android:textSize="24sp" android:layout_gravity="center_vertical" /> </LinearLayout> </LinearLayout> </LinearLayout>
I am using RecyclerView for content under tabs. I use 3 different Fragments for Activity .
Here is my activity:
<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"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:elevation="0dp"> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="0dp" android:background="@color/blue" app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabTextAppearance="@style/TabLayout" app:tabSelectedTextColor="@color/white" app:tabTextColor="@color/white" /> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.CoordinatorLayout>
And here is one of my snippets:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/recycler_view" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.design.widget.CoordinatorLayout>
How to add title above TabLayout and keep normal scroll behavior?
source share