1.TabLayou本事自己是没有该属性的,所以我们就需要用到自定义布局,创建一个xml布局,布局里编写一个TextView。
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:textSize="30dp"
android:textStyle="bold"
android:gravity="center"
android:text="66666"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
2.然后就获取TabLayout的id
fragmentOneTab = (TabLayout) findViewById(R.id.fragment_one_tab);
3.然后用获取到的id点击方法
fragmentOneTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
//选中
@Overrid