一 . 首先把FragmentLayout 碎片 框架搭建好(调用 TableLayout 横向滑动的时候不要忘记导入 依赖)
首先导入依赖 compile 'com.android.support:design:25.2.0'
(右击工程名 倒数第二个 open module settings ---》找到Dependencies ---》右上角加号 ----》尾缀是design:版本号)
二 . 然后在想要的第一个FragmentLayout 碎片中建 XML
利用ViewPager
例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.TabLayout android:layout_width="match_parent" android:layout_height="40dp" android:id="@+id/my_table" app:tabGravity="center" app:tabIndicatorColor="@color/colorAccent" app:tabMode="scrollable" app:tabSelectedTextColor="@color/colorPrimaryDark" app:tabTextColor="@color/colorPrimary" ></android.support.design.widget.TabLayout> <android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/vp"></android.support.v4.view.ViewPager>