How to create a layout like Twitter profile page in Android -


i developping app has page there must header followed multiple recycler views within viewpager. however, not know how "hide" header when scrolling down.

the following layout not work :

- recyclerview     - header     - slidingtablayout     - viewpager         - recyclerview 

because verticaly scrollable view cannot put inside verticaly scollable view. possible create type of layout in way because twitter did :

enter image description here

so how 1 achieve create type of layout?

theorical solution suggestion

if had layout :

- linearlayout     - header     - slidingtablayout     - viewpager         - recyclerview 

and when recyclerview scrolled, move manually every element upwards header progressively "hidden" , viewpager higher, work?

because verticaly scrollable view cannot put inside verticaly scollable view

that not true, can put scrollable view scrollable view. hard manage scrolling events , of times not necesseary. should not nest scrollable views.

however, there interfaces nestedscrollingchild , nestedscrollingparent which, when implemented can hadle scrolling events. commonly used case nesting relativelayout or nestedscrollview within coordinatorlayout. how implement twitter–like layout.

you can find information in blogpost announcing android design support library or many other tutorials. basic layout should use following

<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>      <! -- 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> 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -