在写布局文件时先找到 design导入
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context="com.example.toutiao.MyTabLayout"> <android.support.design.widget.TabLayout android:id="@+id/tablayout" android:layout_width="match_parent" android:layout_height="80dp" app:tabBackground="@color/colorB" app:tabTextAppearance="@android:style/TextAppearance.Holo.Large" app:tabSelectedTextColor="@color/colorPrimary" app:tabTextColor="#000" app:tabMode="scrollable" app:tabIndicatorColor="#fff" ></android.support.design.widget.TabLayout> <android.support.v4.view.ViewPager android:layout_below="@id/tablayout" android:id="@+id/vp" android:layout_width="match_parent" android:layout_height="match_parent"></android.support.v4.view.ViewPager> </RelativeLayout>