Google is committed to advancing racial equity for Black communities. See how.

LeanbackTabLayout

public class LeanbackTabLayout
extends TabLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.widget.HorizontalScrollView
           ↳ com.google.android.material.tabs.TabLayout
             ↳ androidx.leanback.tab.LeanbackTabLayout


TabLayout with some specific customizations related to focus navigation for TV to be used as top navigation bar. The following modifications have been done on the TabLayout: 1. When the focused tab changes the viewpager is also update accordingly. With the default behavior the viewpager is updated only when tab is clicked. 2. Default behaviour is that focus moves to the tab closest to the last focused item inside viewpager on DPAD_UP. With the current change the selected tab gets the focus. 3. Allowing change of current tab only when focus changes from an adjacent tab to current tab or focus changes from an element outside viewpager/tablayout to the viewpager/tablayout. This prevents change of tabs on DPAD_LEFT on the leftmost element inside viewpager and DPAD_RIGHT on the rightmost element inside viewpager.

Summary

Inherited constants

Inherited fields

Public constructors

LeanbackTabLayout(Context context)

Constructs LeanbackTabLayout

LeanbackTabLayout(Context context, AttributeSet attrs)

Constructs LeanbackTabLayout

LeanbackTabLayout(Context context, AttributeSet attrs, int defStyleAttr)

Constructs LeanbackTabLayout

Public methods

void addFocusables(ArrayList<View> views, int direction, int focusableMode)
void setupWithViewPager(ViewPager viewPager)

Protected methods

void onLayout(boolean changed, int left, int top, int right, int bottom)

Inherited methods

Public constructors

LeanbackTabLayout

public LeanbackTabLayout (Context context)

Constructs LeanbackTabLayout

LeanbackTabLayout

public LeanbackTabLayout (Context context, 
                AttributeSet attrs)

Constructs LeanbackTabLayout

LeanbackTabLayout

public LeanbackTabLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Constructs LeanbackTabLayout

Public methods

addFocusables

public void addFocusables (ArrayList<View> views, 
                int direction, 
                int focusableMode)

Parameters
views ArrayList

direction int

focusableMode int

setupWithViewPager

public void setupWithViewPager (ViewPager viewPager)

Parameters
viewPager ViewPager

Protected methods

onLayout

protected void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

Parameters
changed boolean

left int

top int

right int

bottom int