原文地址:http://blog.csdn.net/crazy1235/article/details/42678877
效果:滑动切换;点击标签切换。
代码:https://github.com/ldb-github/Layout_Tab
1、使用ViewPager和PagerTabStrip/PagerTitleStrip进行布局。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.ViewPager android:id="@+id/fifth_vp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"> <android.support.v4.view.PagerTabStrip android:id="@+id/fifth_strip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#7EC0EE" android:padding="10dp"/> </android.support.v4.view.ViewPager> </LinearLayout>