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() {
//选中
@Override
public void onTabSelected(TabLayout.Tab tab) {
TextView inflate = (TextView)

本文介绍了如何在Android中为TabLayout实现点击文字时大小变化的效果。首先,通过创建自定义XML布局文件,包含一个TextView。接着,获取TabLayout的ID,并设置点击事件来改变TextView的字体大小。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



