Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toolbar will not collapse with Scrollview as child of CoordinatorLayout

I am trying to follow the Google Docs on using the CoordinatorLayout but i am having an issue with the ScrollView inside the CoordinatorLayout. Basically, the Toolbar normally would collapse with a RecyclerView or a Listview when scrolling down. Now with a ScrollView it will not collapse.

<android.support.design.widget.CoordinatorLayout     android:layout_width="match_parent"     android:layout_height="match_parent">      <ScrollView         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_behavior="@string/appbar_scrolling_view_behavior"         >          <TextView             android:id="@+id/tv_View"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_gravity="center"             android:gravity="center"             android:text="@string/filler"             style="@style/TextAppearance.AppCompat.Large"             />      </ScrollView>      <android.support.design.widget.AppBarLayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         >         <android.support.v7.widget.Toolbar             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="?attr/actionBarSize"             app:layout_scrollFlags="scroll|enterAlways"             />      </android.support.design.widget.AppBarLayout>      </android.support.design.widget.CoordinatorLayout> 
like image 883
AmaJayJB Avatar asked Jun 04 '15 14:06

AmaJayJB


People also ask

How do I disable scrolling in collapsing Toolbar layout Android?

The solution is simple, we just need to set the app:scrimAnimationDuration=”0" in our collapsing toolbar layout like the below code snippet. Now just run the code and see the results, you will see then there will be no fading animation anymore.

How do you add a title to a collapsing Toolbar?

collapsingToolbarLayout. setTitleEnabled(false); toolbar. setTitle("My Title"); By calling setTitleEnabled(false); , the title appeared in the toolbar.


1 Answers

The ScrollView does not cooperate with the CoordinatorLayout. You have to use NestedScrollView instead of ScrollView

like image 194
TheoK Avatar answered Sep 21 '22 10:09

TheoK