How to create a layout like Twitter profile page in Android

I am developing an application that has a page where there should be a heading, followed by several types of recycler inside the viewpager. However, I do not know how to “hide” the title when scrolling down.

The following layout will not work:

- RecyclerView
    - Header
    - SlidingTabLayout
    - ViewPager
        - RecyclerView

Because the vertical scrollable view cannot be placed in another vertical scalable view. But this type of layout can be created differently because twitter did this:

enter image description here

So how to achieve this type of layout?

Proposal of a theoretical solution

If we had this layout:

- LinearLayout
    - Header
    - SlidingTabLayout
    - ViewPager
        - RecyclerView

And when the RecyclerView scrolls, we will manually move each element up so that the title gradually “hides” and the ViewPager is higher, could it work?

+4
1

, . , . .

NestedScrollingChild NestedScrollingParent, . RelativeLayout NestedScrollView CoordinatorLayout. , Twitter-.

blogpost Android . , ,

<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:layout_height="192dp"
        android:layout_width="match_parent">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:layout_height="?attr/actionBarSize"
                android:layout_width="match_parent"
                app:layout_collapseMode="pin"/>

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

    <! -- Your Scrollable View -->
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

All Articles