3

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

enter image description here

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

enter image description here

Johnny Bones
  • 8,786
  • 7
  • 52
  • 117

2 Answers2

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!

Kavin Prabhu
  • 2,307
  • 2
  • 17
  • 36
  • Thanks a lot . Could you please avoid and remove using hard coded value . –  Jan 07 '16 at 06:44
  • toolbar and appbarlayout height I am talking about .Dynamically cant we make it. –  Jan 07 '16 at 06:47
  • I have used them in `dimens.xml`, so it's not hard coded! I have different values in my `dimens.xml` in various values folder. – Kavin Prabhu Jan 07 '16 at 06:49
  • Cool .Thanks.I have not observed it.I was just checking it. but its working fine. –  Jan 07 '16 at 06:53
1

Set minimum collapsing height

android:minHeight="200dp"