TabLayout
TabLayout provides a horizontal layout to display tabs, it is used by Samsung in their apps to navigate through different screens in the same Activity. It differs from Google’s one by introducing a new theme and new features.
This documentation page provides only the additional features, for a complete documentation of this component please take a look at:
We also suggest you to read Samsung’s One UI design guidelines before you implement this in your app:
- Samsung Developers
- One UI Design Guidelines (page 31-34)
Styles
-
Widget.Design.TabLayout
-
Widget.Design.TabLayout.Light
Avoid using “Widget.MaterialComponents.*” styles.
XML attributes
-
TabLayout_seslTabSubTextAppearance
Sets text-specific styling for sub tabs secondary text.
-
TabLayout_seslTabSubTextColor
Sets sub tabs secondary text color.
-
TabLayout_seslTabSelectedSubTextColor
Sets sub tabs secondary text selected color.
Methods
- Set a custom size for all the tabs.
public void seslSetTabWidth(int width)
- Set a custom icon margin for all the tabs.
public void seslSetIconTextGap(int gap)
- Deprecated. Set tabs text color, with an option to invalidate all the tabs.
public void seslSetTabTextColor(ColorStateList textColor, boolean updateTabView)
- Show or hide a badge without text for the tab at the specified index.
public void seslShowDotBadge(int index, boolean show)
- Show or hide a badge with text for the tab at the specified index.
public void seslShowBadge(int index, boolean show, String content)
public void seslShowBadge(int index, boolean show, String content, String contentDescription)
- Set tabs badge background color.
public void seslSetBadgeColor(int color)
- Set tabs badge text color.
public void seslSetBadgeTextColor(int color)
- Change the view style to sub tabs.
public void seslSetSubTabStyle()
- Set a custom height for the sub tabs indicator.
public void seslSetSubTabIndicatorHeight(int heightPixel)
- Set sub tabs indicator background color.
public void seslSetSubTabSelectedIndicatorColor(int color)
- Set sub tabs secondary text color.
public void seslSetTabSubTextColors(@Nullable ColorStateList color)
public void seslSetTabSubTextColors(int defaultColor, int selectedColor)
- Get sub tabs secondary text color.
public ColorStateList seslGetTabSubTextColors()
Additional tab modes
Samsung’s TabLayout provides two additional tab modes:
- SESL_MODE_FIXED_AUTO: similar to MODE_FIXED, will automatically switch to MODE_SCROLLABLE and resize the tabs depending its content when they won’t fit anymore in the screen.
- SESL_MODE_WEIGHT_AUTO: always resizes the tabs depending its content, will automatically switch to MODE_SCROLLABLE when they won’t fit anymore in the screen.
TabLayout.Tab
A TabLayout’s Tab instance. It differs from Google one by introducing new features.
This documentation page provides only the additional features, for a complete documentation of this component please take a look at Google’s official documentation.
Methods
- Get the secondary text of this tab.
public CharSequence seslGetSubText()
- Set the secondary text displayed on this tab, will show up only with sub tab style.
public Tab seslSetSubText(@Nullable CharSequence text)
- Get the title TextView of this tab.
public TextView seslGetTextView()
- Get the secondary text TextView of this tab.
public TextView seslGetSubTextView()