Add it in your root build.gradle at the end of repositories:
buildscript {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
...
implementation 'com.github.Alan9435:DynamicTabLayout:3.0'
}
<com.gomaji.dynamictablayout.DynamicTabLayout
android:id="@+id/myTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
yourTabLayout.setDividerFactor(3)
For example, when you set the dividerFactor
to 3, the width of each tab will be one-third of the screen width.
Then, you will see the following screen.