Skip to content

Kotlin Library for Solving TabLayout Scrollable Style Issues

Notifications You must be signed in to change notification settings

Alan9435/DynamicTabLayout

Repository files navigation

DynamicTabLayout

This library is available for Android.

When you want your TabLayout to be scrollable but also fill the screen, you can use this library.

Sample

image image

Step 1. Add the JitPack repository to your build file

  Add it in your root build.gradle at the end of repositories:

buildscript {
   repositories {
     ...
     maven { url 'https://jitpack.io' }
   }
}

Step 2. Add the dependency

dependencies {
  ...
  implementation 'com.github.Alan9435:DynamicTabLayout:3.0'
}

Step 3. Replace your TabLayout with DynamicTabLayout

<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" />

Step 4. Set the width of tabs using setDividerFactor

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.

image image

You can view the complete example at here

About

Kotlin Library for Solving TabLayout Scrollable Style Issues

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages