简体   繁体   English

滚动viewpager时,TabLayout中的标签标题不会向上滚动

[英]Tabs title in the TabLayout does not scroll up when the viewpager is scrolled

Hi guys I have a problem setting up my tab layout, I have done it to the best of my ability & knowledge but I cant get it to work. 嗨,大家好,我在设置标签页布局时遇到了问题,我已经尽我所能做到了,但是我无法使其正常工作。 Here is the scenario: As you can see the tabs are stuck at the bottom just above the viewpager 这是场景: 如您所见,选项卡卡在viewpager上方的底部

i have set up the tab layout inside the coordinator layout but when I try to scroll up the tab strips do not move, the view pager overlays and scrolls on top of the tabs. 我已经在协调器布局中设置了选项卡布局,但是当我尝试向上滚动时,选项卡条不动,视图分页器会覆盖并在选项卡顶部滚动。 the tabs are stuck at the bottom, here is my code maybe ou guys can help me: 选项卡停留在底部,这是我的代码,也许你们可以帮助我:

<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" />

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

mTabLayout.setupWithViewPager(mViewPager);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM