我跟随这个教程Android TabLayout Example using ViewPager and Fragments Android TabLayout Example。
但是如果我滑动片段,视图页将不会移动。 我得到了这个结果output I got。 我仅仅按照上述教程进行操作,没有作出任何更改,但当我们滑动片段时,标签不会移动。请帮助我。谢谢。
这是activity_main.xml。
但是如果我滑动片段,视图页将不会移动。 我得到了这个结果output I got。 我仅仅按照上述教程进行操作,没有作出任何更改,但当我们滑动片段时,标签不会移动。请帮助我。谢谢。
这是activity_main.xml。
<LinearLayout
android:id="@+id/main_layout"
android:orientation="vertical"
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"
tools:context=".MainActivity">
<!-- our toolbar -->
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<!-- our tablayout to display tabs -->
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<!-- View pager to swipe views -->
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
tabLayout.setupWithViewPager(yourViewPager);
- Mark