public class LeanbackTabLayout
extends TabLayout

   ↳ 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:

  • When the focused tab changes the viewpager is also update accordingly. With the default behavior the viewpager is updated only when tab is clicked.
  • 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.
  • 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.

ViewPager can be used with this class but some of the behaviour of ViewPager might not be suitable for TV usage. Refer LeanbackViewPager for the modifications done on ViewPager.


Inherited constants