3
  1. I have a imageview inside a CollapsingToolbarLayout which is part of AppBarLayout as shown below. whenever I try to scroll the content by starting the scroll from the imageview It never scrolls, But the moment I scroll from the recyclerview/NestedScrollView it scroll the content. Was this the expected behavior of CoordinatorLayout ? If I want to scroll the content i.e imageview and my recyclerview/NestedScrollView by scrolling the imageview how I can achieve this. Am I missing something here ?

  2. Whenever I try to call recyclerView.smoothScrollBy()/scrollToPosition()/scrollTo() programatically it doesn't scroll the entire content i.e my CoordinatorLayout along with imageview.

<>

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/rootLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

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

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/header"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

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

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

    <android.support.v7.widget.RecyclerView // or NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/recycler"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

<>

Amjed Baig
  • 410
  • 5
  • 9
  • For your 1st question, it seems to be a bug in the AppBarLayout.Behavior: https://code.google.com/p/android/issues/detail?id=176673&q=collapsingToolbarLayout%20scroll&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars – alaeri Jul 08 '15 at 15:27
  • I found the bug report here: http://stackoverflow.com/questions/30706500/collapsingtoolbarlayout-imageview-is-not-scrollable (half of your question might be a duplicate, but these stackoverflow questions were hard to find so maybe it's best to keep it) – alaeri Jul 08 '15 at 15:29

1 Answers1

1

Finally I have a workaround:

Part 1 : I moved the ImageView to the recyclerview and to have the parallax effect I am using the "https://github.com/kanytu/android-parallax-recyclerview/blob/master/library/src/main/java/com/poliveira/parallaxrecyclerview/ParallaxRecyclerAdapter.java"

Part 2 : As its a RecyclerView i can use recyclerView.smoothScrollBy()/scrollToPosition()/scrollTo()

Amjed Baig
  • 410
  • 5
  • 9