TabLayout Indicator自定义

Sar*_*rah 5 android android-tablayout

我一直在搜索如何将Tablayout中的指示器更改为圆形,像这样 在此处输入图片说明

但是我不知道该怎么做,没有任何帮助!

Mat*_*dim 0

1)为选项卡状态创建布局(例如:tab_selected.xml 和 tab_unselected.xml)

2) 使用布局为选项卡设置自定义视图:

//get your tab item
TabLayout.Tab tabItem = tabLayout.getTabAt(i);
//inflate your layout to a view and set it as the tab's custom view
tabItem.setCustomView(customView);
Run Code Online (Sandbox Code Playgroud)

3)然后,使用setOnTabSelectedListener,继续监听选择了哪个选项卡并相应地更新其自定义视图(使用setCustomView