工具栏未在CoordinatorLayout中滚动时折叠

车祸

我正在使用以下布局文件来实现带有折叠工具栏的协调器布局(当用户向下滚动时,它应该折叠,并在向上滚动时重新出现)。但是,这种滚动屏幕/折叠功能不起作用,我不知道不知道为什么。工具栏和选项卡栏没有反应,而是静态地停留在屏幕顶部。

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <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="wrap_content"
            android:orientation="vertical" >

            <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Alpha" />
            <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Beta" />
            <!-- a bunch of content just to make the view long enough to scroll -->
            <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Upsilon" />

        </LinearLayout>

    </ScrollView>


    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorAccent"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_scrollFlags="scroll|enterAlways" />
            <!--                    ^^^^^^^^^^^^^^^^^^ -->

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways" />
            <!--                    ^^^^^^^^^^^^^^^^^^ -->

    </android.support.design.widget.AppBarLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_padding"
        android:src="@drawable/ic_add"/>

</android.support.design.widget.CoordinatorLayout>

有什么帮助吗?谢谢!

邹国荣

据我所知,ScrollView不起作用。您可以改用NestedScrollViewRecyclerView

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

滚动时的Android工具栏高度

作为Scrollview的CoordinatorLayout的子代,工具栏不会折叠

滚动时如何在折叠的工具栏中修复视图?

滚动时Android“隐藏”工具栏

滚动标签中的片段时隐藏/显示工具栏

折叠工具栏折叠时隐藏浮动按钮

CoordinatorLayout中工具栏下方的进度栏

当折叠的工具栏折叠时,如何更改其颜色?

无法从折叠的工具栏中显示工具栏

块滚动以及“展开/折叠可折叠工具栏”

滚动时工具栏不会隐藏

折叠时,在折叠工具栏中设置主题

滚动到不带工具栏的折叠视图

CoordinatorLayout中的Viewpager无法滚动“折叠”工具栏

CoordinatorLayout带有折叠的工具栏,NestedScrollView和RecyclerView底部有空白空间(滚动太远)

Android:滚动时如何在折叠的工具栏中更改视图

折叠工具栏-禁用触摸滚动

如何解决折叠的工具栏滚动问题

工具栏未在iOS中显示

Android CoordinatorLayout:仅在列表开始滚动时滚动工具栏

工具栏不会折叠,因为在滚动过程中应使用TabLayout

折叠时折叠工具栏锚定视图被隐藏

片段中Activity中的CoordinatorLayout折叠工具栏

Android中的视差滚动/可折叠工具栏

折叠工具栏在协调器布局中滚动时不会折叠

在视图寻呼机中滚动时折叠工具栏不会折叠

平铺未在折叠工具栏中居中

CoordinatorLayout + CollapsingToolbarLayout 向上滚动时不设置工具栏

CoordinatorLayout 仅在特定片段中滚动时隐藏工具栏