explaingit

ogaclejapan/smarttablayout

7,077JavaAudience · developerComplexity · 2/5Setup · easy

TLDR

An Android library that replaces the default ViewPager tab strip with a smoothly animated sliding indicator that moves continuously as the user drags between sections, with extensive visual customization via XML.

Mindmap

mindmap
  root((SmartTabLayout))
    What it does
      Smooth tab indicator
      Continuous animation
      XML customization
    Tech Stack
      Java
      Android
      AndroidX
    Visual Options
      Indicator color and size
      Divider lines
      Font and padding
    Use Cases
      Tabbed Android apps
      Custom tab designs
      Swipeable sections
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a smooth sliding tab indicator to an Android app that uses ViewPager for swipeable sections.

USE CASE 2

Customize the tab strip appearance, indicator color, width, thickness, corner radius, directly in XML without extra Java code.

USE CASE 3

Supply fully custom views for each tab, such as icon-only tabs or tabs with notification badges.

Tech stack

JavaAndroidAndroidX

Getting it running

Difficulty · easy Time to first run · 30min

Requires an existing Android project with ViewPager already set up.

In plain English

Many Android apps display a row of tabs near the top of the screen, letting users swipe left and right between different sections. A small colored bar slides under the active tab to show which section you are on. Android has a built-in component for this called ViewPager, but the default tab strip it offers has limited visual feedback and customization options. SmartTabLayout is a Java library for Android that replaces that default tab strip with a more polished one. The main improvement is that the indicator bar moves continuously and smoothly as the user drags the screen between sections, rather than jumping from one position to another only after the swipe completes. This makes the navigation feel more responsive. The library offers a wide range of visual options you can set directly in your XML layout file without writing extra code: the color, width, thickness, and corner radius of the sliding indicator, whether it sits at the top or bottom of the tab strip, the color and thickness of divider lines between tabs, whether tabs share equal width, whether the active tab stays centered like in some Google apps, and the font size, color, and padding of the tab text. You can also supply a fully custom view for each tab if the built-in options are not enough. Setup involves adding the library as a dependency in your Android project's build file, placing the SmartTabLayout widget in your screen's XML layout above the ViewPager, and connecting the two with a single line of Java code. The README includes a demo app available on Google Play to preview the different visual styles before integrating. The library builds on an older Google sample project and adds additional features and configuration options. It supports both the newer AndroidX support libraries and older legacy support library versions of Android.

Copy-paste prompts

Prompt 1
Add SmartTabLayout to my Android project and connect it to a ViewPager with three fragment tabs, show me the XML layout and Java setup code.
Prompt 2
How do I set the tab indicator color, height, and corner radius in SmartTabLayout using XML attributes?
Prompt 3
How do I supply a custom view for each tab in SmartTabLayout instead of using text labels?
Prompt 4
Does SmartTabLayout work with ViewPager2 and AndroidX, or do I need the legacy support library version?
Open on GitHub → Explain another repo

← ogaclejapan on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.