先上效果图
主要用到了ViewPager,TableLayout,Fragment的组合
首先,要使用TabLayout必须在AndroidStudio中导入这个依赖库
compile 'com.android.support:design:23.1.1'
主界面的布局
一个TabLayout和一个ViewPager
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
>
<android.support.design.widget.TabLayout
android:id="@+id/main_tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabSelectedTextColor="@android:color/white"
app:tabTextColor="#000000"
app:tabIndicatorColor="#FF4081"
app:tabGravity="fill"
app:tabBackground="@android:color/holo_blue_bright">
</android.support.design