Tablayout不坚持

时间:2015-08-05 07:27:25

标签: android toolbar android-coordinatorlayout

我正在使用工具栏和tablayout。下面是我的主要xml文件

<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

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

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/sliding_tabs"
            style="@style/MyCustomTabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>


<android.support.v4.view.ViewPager
    android:id="@+id/pager_booking_mng"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

在此当前代码工具栏中不滚动。当我滚动列表时。

但是当我在Tablayout标签中设置app:layout_scrollFlags =“scroll | enterAlways”时,tablaout和工具栏都在滚动,两者都在屏幕之外。

我只想滚动工具栏,tablayout应该固定在顶部(就像whatsapp一样)。

1 个答案:

答案 0 :(得分:0)

将Tablayout的滚动标记设为

应用程式:layout_scrollFlags =&#34;滚动| enterAlwaysCollapsed&#34;

希望这会奏效。

相关问题