6
TabLayout实现Tab自定义宽度
source link: https://renyugang.blog.csdn.net/article/details/108590808
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
TabLayout实现Tab自定义宽度
晚上在做一个效果的时候,纠结在这个Tab自定义控件的宽度设置上,看了下网上没什么资料,就分享一下。<com.google.android.material.tabs.TabLayout
android:id="@+id/emojiTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabBackground="@null"
app:tabRippleColor="@null"
app:tabIndicator="@null"
app:tabPaddingEnd="0dp"
app:tabPaddingStart="0dp"
app:tabMinWidth="0dp"
app:tabMaxWidth="0dp"/>
app:tabMinWidth=“0dp”
设置掉默认的一个最小宽度
Kotlin:
tabLayout.newTab().apply {
customView = LayoutInflater.from(applicationContext)
.inflate(
R.layout.custom_tab_item,
null,
false
).apply {
// do something
}
}.also {
tabLayout.addTab(it)
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK