LeanbackTabLayout
open class LeanbackTabLayout : 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
.
Summary
Public constructors | |
---|---|
Constructs LeanbackTabLayout |
|
<init>(@NonNull context: Context, @NonNull attrs: AttributeSet) Constructs LeanbackTabLayout |
|
<init>(@NonNull context: Context, @NonNull attrs: AttributeSet, defStyleAttr: Int) Constructs LeanbackTabLayout |
Public methods | |
---|---|
open Unit |
addFocusables(@NonNull views: ArrayList<View!>, direction: Int, focusableMode: Int) |
open Unit |
setupWithViewPager(@Nullable viewPager: ViewPager?) |
Protected methods | |
---|---|
open Unit |
Public constructors
<init>
LeanbackTabLayout(@NonNull context: Context)
Constructs LeanbackTabLayout
Parameters | |
---|---|
context |
Context: |
<init>
LeanbackTabLayout(
@NonNull context: Context,
@NonNull attrs: AttributeSet)
Constructs LeanbackTabLayout
Parameters | |
---|---|
context |
Context: |
attrs |
AttributeSet: |
<init>
LeanbackTabLayout(
@NonNull context: Context,
@NonNull attrs: AttributeSet,
defStyleAttr: Int)
Constructs LeanbackTabLayout
Parameters | |
---|---|
context |
Context: |
attrs |
AttributeSet: |
defStyleAttr |
Int: |
Public methods
addFocusables
open fun addFocusables(
@NonNull views: ArrayList<View!>,
direction: Int,
focusableMode: Int
): Unit