简体   繁体   English

我无法在CoordinatorLayout中隐藏工具栏

[英]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 但是隐藏工具栏不起作用

ScrollView won't associate with Coordinator layout. ScrollView不会与协调器布局关联。 Use NestedScrollView instead of ScrollView. 使用NestedScrollView而不是ScrollView。 It'll Work. 会的

here 这里

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.

相关问题 使用CoordinatorLayout滚动隐藏工具栏 - Hide Toolbar on scroll with CoordinatorLayout 在CoordinatorLayout上以编程方式隐藏/显示工具栏 - Hide/Show Toolbar programmatically on CoordinatorLayout 使用CoordinatorLayout隐藏工具栏,但在片段上使用RecyclerView - Hide Toolbar with CoordinatorLayout, but RecyclerView on a fragment 使用CoordinatorLayout从片段中隐藏活动中的工具栏 - Hide Toolbar in activity from fragment using CoordinatorLayout 工具栏不会在CoordinatorLayout中滚动时隐藏/显示 - Toolbar does not Hide/Shown on Scrolling in CoordinatorLayout 滚动时隐藏工具栏无法正常工作[CoordinatorLayout] - Hide Toolbar on scroll wont work properly [CoordinatorLayout] 仅在特定片段中滚动时,CoordinatorLayout 隐藏工具栏 - CoordinatorLayout hide toolbar when scrolling only in specific fragment android - CoordinatorLayout / NestedScrollView /隐藏 - 显示工具栏/ WebView问题 - android - CoordinatorLayout/NestedScrollView/Hide-Show Toolbar/Issue with WebView 使用CoordinatorLayout时如何隐藏工具栏的一部分内容 - How to hide part of content of the toolbar when using CoordinatorLayout 工具栏不可见“无法使用CoordinatorLayout制作装饰工具栏” - Toolbar not Visible “Can't make a decor toolbar out of CoordinatorLayout”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM