您好,我正在使用viewpager进行标签布局,我想使项目能够自行调整大小或在用户单击时进行调整。我做了如下代码:
val viewPager = findViewById<ViewPager>(R.id.view_pager)
viewPager.adapter = ViewPagerAdapter(
supportFragmentManager, PAGE_POSITION
)
val tab = findViewById<TabLayout>(R.id.tab_layout)
tab.setupWithViewPager(viewPager)
val params = tab.layoutParams
params.height = 250
tab.layoutParams = params
tab.getTabAt(0)!!.setIcon(tabIcons[0])
tab.getTabAt(1)!!.setIcon(tabIcons[1])
tab.getTabAt(2)!!.setIcon(tabIcons[2])
tab.getTabAt(3)!!.setIcon(tabIcons[3])
tab.getTabAt(4)!!.setIcon(tabIcons[4])