1.TabLayou本事自己是没有该属性的,所以我们就需要用到自定义布局,创建一个xml布局,布局里编写一个TextView。
2.然后就获取TabLayout的id
fragmentoneTab = (TabLayout) findViewById(R.id.fragment_one_tab);
3.然后用获取到的id点击方法
fragmentOneTab.addOnTabSelectedListener(new TabLayout.onTabSelectedListener() {
//选中
@Override
public void onTabSelected(TabLayout.Tab tab) {
TextView inflate = (TextView)
LayoutInflater.from(getContext()).inflate(R.layout.text, null);
//设置点击后的字体大小
inflate.setTextSize(30);
//设置点击的内容
inflate.setText(tab.getText());
//获取布局
tab.setCustomView(inflate);
}
//未选中的
@Override
public void onTabUnselected(TabLayout.Tab tab) {
tab.setCustomView(null);
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});



