[英]I can not hide Toolbar in CoordinatorLayout
我已附加的xml具有ScrollView,其中包含一些imageview以测试工具栏是否可以隐藏。 就我而言,事实并非如此。
我已经使用buildToolsVersion "22.0.1"
并compile 'com.android.support:appcompat-v7:22.2.0'
并compile 'com.android.support:design:22.2.0'
有什么解决方案?
我的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>
但是隐藏工具栏不起作用
ScrollView不会与协调器布局关联。 使用NestedScrollView而不是ScrollView。 会的
它发生在我身上。 我将ContraintLayout与CoordinatorLayout混淆了。 这是“您已关闭电源然后又打开电源”的一种,在那儿我读得不够认真。 花了我3个小时来了解为什么我的工具栏没有隐藏。 不要让这种情况发生在您身上,尤其是当您使用由Android Studio生成的模板化活动布局时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.