[英]I can not hide Toolbar in CoordinatorLayout
I have attached xml has a ScrollView which include some imageview to test that toolbar can hide or not. 我已附加的xml具有ScrollView,其中包含一些imageview以测试工具栏是否可以隐藏。 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'
我已经使用
buildToolsVersion "22.0.1"
并compile 'com.android.support:appcompat-v7:22.2.0'
并compile 'com.android.support:design:22.2.0'
What is the solution for that ? 有什么解决方案?
My xml is as below : 我的xml如下:
<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 但是隐藏工具栏不起作用
It happened to me. 它发生在我身上。 I confused the ContraintLayout with CoordinatorLayout.
我将ContraintLayout与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.
花了我3个小时来了解为什么我的工具栏没有隐藏。 Don't let this happen to you, especially if you use templated activity layout generated by Android Studios.
不要让这种情况发生在您身上,尤其是当您使用由Android Studio生成的模板化活动布局时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.