提问者:小点点

有没有办法设置一个标题和副标题com.google.android。


TabLayoutMediator(
            tabbedFragmentView.tabs,tabbedFragmentView.view_pager)
 { tab, position ->
            tab.text = tabFragmentList[position].title
 }.attach()

我找不到设置字幕的方法,只有一个设置文本功能可用,它将是选项卡布局选项卡的主标题,如果我也想要一个字幕呢。


共2个答案

匿名用户

您需要为选项卡设置自定义视图:

TabLayoutMediator(tabbedFragmentView.tabs, tabbedFragmentView.view_pager) { tab, position -> 
    val customTabView = View() // inflate your custom view here
    // set title and subtitle
    tab.setCustomView(customTabView)
}.attach()

匿名用户

tabLayout with viewageer2:你可以引用这个链接

TabLayoutMediator(tabLayout, viewPager) { tab, position ->
tab.text = tabTitles[position]
viewPager.setCurrentItem(tab.position, true)
}.attach()