TabLayout - OneUIProject/OneUI-Design-Library GitHub Wiki

de.dlyt.yanndroid.oneui.widget.TabLayout

Samsung's TabLayout.

<de.dlyt.yanndroid.oneui.widget.TabLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

If you want to set it up with a ViewPager you'll have to use the ViewPager (implementation) bundled in the library, the usage is the same as Google's TabLayout.

Methods

Add a custom ImageButton like in Samsung's Gallery (as seen in screenshot).

public void addTabCustomButton(Drawable icon, CustomButtonClickListener listener)

Set the style to:

public void seslSetSubTabStyle()

Show a badge.

public void seslShowDotBadge(int index, boolean show)

public void seslShowBadge(int index, boolean show, int badge)
public void seslShowBadge(int index, boolean show, String text)
public void seslShowBadge(int index, boolean show, String text, String contentDescription)

Set Colors.

public void seslSetTabSubTextColors(ColorStateList color)
public void seslSetTabSubTextColors(int defaultColor, int selectedColor)
public ColorStateList seslGetTabSubTextColors()

public void seslSetBadgeColor(@ColorInt int color)
public void seslSetBadgeTextColor(@ColorInt int color)

public void seslSetSubTabSelectedIndicatorColor(@ColorInt int color)

Set Sizes.

public void seslSetIconTextGap(int gap)
public void seslSetSubTabIndicatorHeight(int height)
public void seslSetTabWidth(int width)

Tab

Returns tab title/subtext textview (only for sub tabs).

public TextView seslGetTextView()
public TextView seslGetSubTextView()

Set sub text (only for sub tabs).

public CharSequence seslGetSubText()
public Tab seslSetSubText(@Nullable CharSequence subText)

Samsung's Tab has two additional modes (not working in RTL currently):

  • SESL_MODE_FIXED_AUTO: auto switch to scrollable mode, tabs have all the same size
  • SESL_MODE_WEIGHT_AUTO: auto switch to scrollable mode, tabs have individual size depending the content
public void setTabMode(@Mode int mode)
public int getTabMode()