如何以编程方式显示TabLayout,这是以前通过app隐藏的:layout_scrollFlags =" scroll | enterAlways | snap"

时间:2016-03-18 13:58:49

标签: android

目前,我在滚动期间隐藏了TabLayout(我的ViewPager包含多个片段,而这些片段又包含RecyclerView)。

<?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:id="@+id/coordinator_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways|snap">

            <android.support.design.widget.TabLayout
                android:id="@+id/tab_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabIndicatorColor="?attr/portfolioTabIndicatorColor" />

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

    <!-- app:layout_behavior="@string/appbar_scrolling_view_behavior" -->
    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />    
</android.support.design.widget.CoordinatorLayout>

当我将ViewPager滑动到选定的Fragment时,我想以编程方式再次显示TabLayout,而不执行任何滚动。我可以知道如何实现这一目标吗?

0 个答案:

没有答案