代码之家  ›  专栏  ›  技术社区  ›  Will

滚动时如何隐藏选项卡

  •  -3
  • Will  · 技术社区  · 6 年前

    我用的是 FrameLayout NestedScrollView 在上面我打开了一个有3个标签的片段。

    ActionBar .

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|enterAlways"
        tools:context=".MainActivity">
    
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_collapseMode="pin"
                app:layout_scrollFlags="enterAlways|scroll" />
    
        </android.support.design.widget.AppBarLayout>
    
        <!--<include layout="@layout/content_main" />-->
    
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/main_container"
            android:background="@color/colorPrimary"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
            <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="true">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
                    <!-- Your content here -->
                </LinearLayout>
            </android.support.v4.widget.NestedScrollView>
        </FrameLayout>
    
        <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_margin"
            app:srcCompat="@android:drawable/ic_dialog_email" />
    
    </android.support.design.widget.CoordinatorLayout>
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   ʍѳђઽ૯ท    6 年前

    有没有可能在隐藏标签的同时滚动?

    第一: Toolbar ,您已设置: app:layout_collapseMode="pin" 这意味着它将被钉在顶部。之后, app:layout_scrollFlags="enterAlways|scroll" Activity .

    所以,删除: 工具栏 .

    去除 app:layout_scrollFlags="scroll|enterAlways" CoordinatorLayout

    我什么也看不见 制表符 layout ,我想你正在使用 TabLayout Fragment s、 如果你想藏起来 表布局 工具栏 ,地点 FrameLayout 在里面 NestedScrollView 表布局 工具栏 在里面 AppBarLayout

    app:layout_scrollFlags="enterAlways|scroll"
    

    对双方 工具栏 表布局