【问题标题】:Tabs title in the TabLayout does not scroll up when the viewpager is scrolled滚动 viewpager 时 TabLayout 中的选项卡标题不会向上滚动
【发布时间】:2016-06-03 07:27:47
【问题描述】:

大家好,我在设置标签布局时遇到问题,我已尽我的能力和知识做到了,但我无法让它工作。 这是场景: As you can see the tabs are stuck at the bottom just above the viewpager

我已经在协调器布局中设置了标签布局,但是当我尝试向上滚动标签条时,标签条不会移动,视图寻呼机覆盖并在标签顶部滚动。标签卡在底部,这是我的代码,也许你们可以帮助我:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res-auto" app:id="@+id/coordinatorLayout" app:layout_width="match_parent" app:layout_height="match_parent">
<android.support.design.widget.AppBarLayout app:theme="@style/ThemeOverlay_AppCompat_Dark_ActionBar" app:id="@+id/mapAppbar" app:fitsSystemWindows="true" app:layout_width="match_parent" app:layout_height="UNKNOWN_DATA_0x1f401">
    <android.support.design.widget.CollapsingToolbarLayout app:id="@+id/main_collapsing" app:fitsSystemWindows="true" app:layout_width="match_parent" app:layout_height="match_parent" app:layout_scrollFlags="3" app:expandedTitleMarginStart="48dp" app:expandedTitleMarginEnd="64dp" app:contentScrim="#f15524">
        <fragment android:name="com.google.android.gms.maps.SupportMapFragment" android:id="@+id/map" android:fitsSystemWindows="true" android:layout_width="match_parent" android:layout_height="UNKNOWN_DATA_0x1f401" android:layout_scrollFlags="5" android:layout_collapseMode="2" />
        <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="UNKNOWN_DATA_0x7f010047" android:popupTheme="@style/ThemeOverlay_AppCompat_Light" android:layout_collapseMode="1" />
        <android.support.design.widget.TabLayout android:layout_gravity="top|bottom|center_vertical|fill_vertical|center|fill" android:id="@+id/tabLayout" android:layout_width="match_parent" android:layout_height="UNKNOWN_DATA_0x7f010047" android:layout_collapseMode="1" android:tabIndicatorColor="#233" android:tabMode="0" android:tabTextColor="#1b1b1b" android:tabSelectedTextColor="#fff" />
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton android:layout_gravity="top|bottom|left|right|center_vertical|fill_vertical|center_horizontal|fill_horizontal|center|fill|start|end" android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:fabSize="1" />

【问题讨论】:

  • 我无法理解您的要求,而且您指向快照图像的链接也没有显示任何选项卡。你可以解释吗?要实现nestedScrollView 功能吗?
  • 谢谢,底部有标签,就在谷歌徽标旁边(右下)。我试图实现折叠工具栏布局,但我不能让他的标签与其他内容一起滚动,它们总是留在底部并隐藏在 viewpager 后面

标签: android android-tablayout android-coordinatorlayout


【解决方案1】:

尝试将此代码添加到您的课程中:

mTabLayout.setupWithViewPager(mViewPager);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-05
    • 1970-01-01
    • 1970-01-01
    • 2015-11-17
    • 1970-01-01
    相关资源
    最近更新 更多