Skip to main content

Components

Tab Bar

Displays a tab bar to switch different views

banner-Tab Bar

Tabs organize content across different screens, data sets, and other interactions.

Usage

You can implement Tabs by using this tag LgnTabLayout in xml file.

<com.telkom.legion.component.tabbar.LgnTabLayout
android:id="@+id/tabBase"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

You can alse customize the Tabs in the fragment or activity from Kotlin file .

Tabs adapter

...
class CommonPagerAdapters(
fragment: Fragment,
val data: List<Fragment>
) : FragmentStateAdapter(fragment) {
override fun getItemCount(): Int {
return data.size
}

Activity or Fragment file

...
with(binding) {
...
// Configure ViewPager2 with Adapter
vpBase.adapter = CommonPagerAdapters(listFragment)
// Attach Tab to ViewPager2
TabLayoutMediator(this, viewPager2) { tab, position ->
tab.text = label[position]
}.attach()
## Attributes
Attribute NameXml AttrsRelated method(s)Description
Tab indicator colorapp:tabIndicatorColorsetSelectedTabIndicatorColor()Change Tab indicator color
Tab indicatorapp:tabIndicatorsetSelectedTabIndicatorColor()Change Tab indicator
Tab indicator gravityapp:tabIndicatorGravitysetSelectedTabIndicatorGravity()Change Tab indicator gravity
Tab indicator animation modeapp:tabIndicatorAnimationMode.tabIndicatorAnimationModeChange Tab indicator animation mode
Tab modeapp:tabMode.tabModeChange Type of Tab Style
Tab inline labelapp:tabInlineLabel.isInlineLabelChange Tab Label Position to Inline
Tab text colorsapp:tabTextColor.tabTextColorsChange Tab Text Color State Not Selected
Tab text colors selectedapp:tabSelectedTextColor.tabTextColorsChange Tab Text Color State Not Selected
Tab paddingapp:tabPaddingN/AChange Tab all padding
Tab padding startapp:tabPaddingStartN/AChange Tab start padding
Tab padding topapp:tabPaddingTopN/AChange Tab top padding
Tab padding endapp:tabPaddingEndN/AChange Tab end padding
Tab padding bottomapp:tabPaddingBottomN/AChange Tab bottom padding
Tab text appreanceapp:tabTextAppearanceN/AChange Tab text apreance
Tab backgroundapp:tabBackgroundN/AChange Tab background
Tab indicator animation durationapp:tabIndicatorAnimationDurationN/AChange Tab indicator animation duration]