I have attached xml has a ScrollView which include some imageview to test that toolbar can hide or not. In my case it doesn't.
I have used buildToolsVersion "22.0.1"
and compile 'com.android.support:appcompat-v7:22.2.0'
and compile 'com.android.support:design:22.2.0'
What is the solution for that ?
My xml is as below :
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toorbar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/drawer_header"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/drawer_header"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/drawer_header"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/drawer_header"/>
</LinearLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
but it not work to hide toolbar
ScrollView won't associate with Coordinator layout. Use NestedScrollView instead of ScrollView. It'll Work.
It happened to me. I confused the ContraintLayout with CoordinatorLayout. It's one of those "have you switch off and switch on yet", where I didn't read hard enough. Took me 3 hours to understand why my toolbar wasn't hiding. Don't let this happen to you, especially if you use templated activity layout generated by Android Studios.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.