簡體   English   中英

我無法在CoordinatorLayout中隱藏工具欄

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM