Android 12 Developer Preview is here! Try it out, and give us your feedback!


open class LeanbackViewPager : ViewPager
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ androidx.viewpager.widget.ViewPager

A viewpager with touch and key event handling disabled by default.

Key events handling is disabled by default as with the behaviour of viewpager the fragments can change when DPAD keys are pressed and focus is on the content inside the ViewPager. This is not desirable for a top navigation bar. The fragments should preferably change only when the focused tab changes.


Inherited constants
Public constructors
<init>(@NonNull context: Context)

Constructs LeanbackViewPager

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

Constructs LeanbackViewPager

Public methods
open Boolean
executeKeyEvent(@NonNull event: KeyEvent)

open Boolean

open Boolean
onTouchEvent(@NonNull event: MotionEvent)

open Unit
setKeyEventsEnabled(enableKeyEvent: Boolean)

Setter for enabling/disabling key events

open Unit
setTouchEnabled(enableTouch: Boolean)

Setter for enabling/disabling touch events

Inherited functions