1

My collapsingtoolbar layout consists of an image. I want that image to be stopped scrolling before say 270dp and then only scroll the remaining content.

I had already followed 2 answers on Stackoverflow but that doesn't seems to work for me.

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

Layout xml

       <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="wrap_content"
    android:animateLayoutChanges="true">


    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:contentScrim="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">


                <ImageView
                    android:id="@+id/toolbar_imgview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:adjustViewBounds="true"
                    android:scaleType="centerCrop"
                    app:layout_collapseMode="parallax" />

                <android.support.v7.widget.Toolbar

                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="@android:color/transparent"
                    app:layout_collapseMode="pin" />

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

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

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nestedscroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/app_bar_layout"
            android:background="#ffff"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/toolbar_shadow_height"
                    android:background="@drawable/shape_shadow" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#ffff"
                    android:weightSum="1.0">

                    <Button
                        android:layout_width="0dip"
                        android:layout_height="40dp"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginRight="10dp"
                        android:layout_weight=".5"
                        android:background="@drawable/button_bg"
                        android:text="Set Wallpaper"
                        android:textColor="#ff4081"
                        android:textSize="12dp" />

                    <Button
                        android:layout_width="0dip"
                        android:layout_height="40dp"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:layout_weight=".5"
                        android:background="@drawable/button_bg_dw"
                        android:text="Download"
                        android:textColor="#FFFF"
                        android:textSize="12dp" />

                </LinearLayout>


                <View
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:background="?attr/dividerHorizontal" />


                <include
                    layout="@layout/activity_details"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />


            </LinearLayout>

        </android.support.v4.widget.NestedScrollView>


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

</RelativeLayout>

I have tried setting the height of AppBarLayout as 280dp but it was of no use. I'm setting image through Universal Image Loader.

Community
  • 1
  • 1
Jack Stern
  • 395
  • 1
  • 4
  • 16

0 Answers0