android - Scrolling with Collapsing Toolbar and Tabs -


i'm trying make layout collapsingtoolbarlayout has scroll|exituntilcollapsed flag, , tablayout has scroll|enteralways scrollflag property. want toolbar pinned , show , hide tabs while scrolling. i've modified cheesesquare app https://github.com/chrisbanes/cheesesquare. here layout xml;

<?xml version="1.0" encoding="utf-8"?>  <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/main_content"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:fitssystemwindows="true">      <android.support.design.widget.appbarlayout         android:id="@+id/appbar"         android:layout_width="match_parent"         android:layout_height="@dimen/detail_backdrop_height"         android:theme="@style/themeoverlay.appcompat.dark.actionbar"         android:fitssystemwindows="true">          <android.support.design.widget.collapsingtoolbarlayout             android:id="@+id/collapsing_toolbar"             android:layout_width="match_parent"             android:layout_height="match_parent"             app:layout_scrollflags="scroll|exituntilcollapsed"             android:fitssystemwindows="true"             app:contentscrim="?attr/colorprimary"             app:expandedtitlemarginstart="48dp"             app:expandedtitlemarginend="64dp">              <imageview                 android:id="@+id/backdrop"                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:scaletype="centercrop"                 android:fitssystemwindows="true"                 app:layout_collapsemode="parallax" />              <android.support.v7.widget.toolbar                 android:id="@+id/toolbar"                 android:layout_width="match_parent"                 android:layout_height="?attr/actionbarsize"                 app:popuptheme="@style/themeoverlay.appcompat.light"                 app:layout_collapsemode="pin" />              <android.support.design.widget.tablayout                 android:id="@+id/tabs"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 app:layout_scrollflags="scroll|enteralways"                 app:layout_behavior="@string/appbar_scrolling_view_behavior"/>          </android.support.design.widget.collapsingtoolbarlayout>      </android.support.design.widget.appbarlayout>      <android.support.v4.view.viewpager         android:id="@+id/viewpager"         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_behavior="@string/appbar_scrolling_view_behavior" />      <android.support.design.widget.floatingactionbutton         android:layout_height="wrap_content"         android:layout_width="wrap_content"         app:layout_anchor="@id/appbar"         app:layout_anchorgravity="bottom|right|end"         android:src="@drawable/ic_discuss"         android:layout_margin="@dimen/fab_margin"         android:clickable="true"/>  </android.support.design.widget.coordinatorlayout> 

and here result;

the tabs not positioned properly. , don't care enteralways property.

enter image description here

hey this may solve problem.

just add android:layout_gravity="bottom" tablayout , android:gravity="top" tollbar.

enter image description here


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -