How to Stop scroll on CollapsingToolbarLayout so it doesn't completely collapse

匿名 (未验证) 提交于 2019-12-03 08:56:10

问题:

Hi Everone could you please suggest me how to stop it .please have a look at following screenshot.

After scrolling up it should stop below app tool bar minimum 200dp from TOP

回答1:

You can do something like below

<?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"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:fitsSystemWindows="true">      <android.support.design.widget.AppBarLayout         android:id="@+id/app_bar"         android:layout_width="match_parent"         android:layout_height="@dimen/app_bar_height" //280dp         android:fitsSystemWindows="true"         android:theme="@style/AppTheme.AppBarOverlay">          <android.support.design.widget.CollapsingToolbarLayout             android:id="@+id/toolbar_layout"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:fitsSystemWindows="true"             app:contentScrim="?attr/colorPrimary"             app:layout_scrollFlags="scroll|exitUntilCollapsed">              <android.support.v7.widget.Toolbar                 android:id="@+id/toolbar"                 android:layout_width="match_parent"                 android:layout_height="@dimen/my_toolbar_bar_height" //200dp                 app:layout_collapseMode="pin"                 app:popupTheme="@style/AppTheme.PopupOverlay"/>          </android.support.design.widget.CollapsingToolbarLayout>    </android.support.design.widget.AppBarLayout>  <include layout="@layout/content_scrolling"/> // This is place holder for content/list  </android.support.design.widget.CoordinatorLayout> 

AppBarLayout height will be greater the Toolbar height (In your scenario Toolbar height is 200dp so I kept AppBarLayout as 280dp) Hope this is what you looking for!



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!