OnboardingSupportFragment

abstract class OnboardingSupportFragment : Fragment


An OnboardingSupportFragment provides a common and simple way to build onboarding screen for applications.

Building the screen

The view structure of onboarding screen is composed of the common parts and custom parts. The common parts are composed of icon, title, description and page navigator and the custom parts are composed of background, contents and foreground.

To build the screen views, the inherited class should override:

  • onCreateBackgroundView to provide the background view. Background view has the same size as the screen and the lowest z-order.
  • onCreateContentView to provide the contents view. The content view is located in the content area at the center of the screen.
  • onCreateForegroundView to provide the foreground view. Foreground view has the same size as the screen and the highest z-order

Each of these methods can return null if the application doesn't want to provide it.

Page information

The onboarding screen may have several pages which explain the functionality of the application. The inherited class should provide the page information by overriding the methods:

Note that the information is used in onCreateView, so should be initialized before calling super.onCreateView.

Animation

Onboarding screen has three kinds of animations: Logo Splash Animation When onboarding screen appears, the logo splash animation is played by default. The animation fades in the logo image, pauses in a few seconds and fades it out.

In most cases, the logo animation needs to be customized because the logo images of applications are different from each other, or some applications may want to show their own animations.

The logo animation can be customized in two ways:

If the inherited class provides neither the logo image nor the animation, the logo animation will be omitted.

Page enter animation After logo animation finishes, page enter animation starts, which causes the header section - title and description views to fade and slide in. Users can override the default fade + slide animation by overriding onCreateTitleAnimator&onCreateDescriptionAnimator. By default we don't animate the custom views but users can provide animation by overriding onCreateEnterAnimation. Page change animation When the page changes, the default animations of the title and description are played. The inherited class can override onPageChanged to start the custom animations.

Finishing the screen

If the user finishes the onboarding screen after navigating all the pages, onFinishFragment is called. The inherited class can override this method to show another fragment or activity, or just remove this fragment.

Theming

OnboardingSupportFragment must have access to an appropriate theme. Specifically, the fragment must receive Theme_Leanback_Onboarding, or a theme whose parent is set to that theme. Themes can be provided in one of three ways:

  • The simplest way is to set the theme for the host Activity to the Onboarding theme or a theme that derives from it.
  • If the Activity already has a theme and setting its parent theme is inconvenient, the existing Activity theme can have an entry added for the attribute LeanbackOnboardingTheme_onboardingTheme. If present, this theme will be used by OnboardingSupportFragment as an overlay to the Activity's theme.
  • Finally, custom subclasses of OnboardingSupportFragment may provide a theme through the onProvideTheme method. This can be useful if a subclass is used across multiple Activities.

If the theme is provided in multiple ways, the onProvideTheme override has priority, followed by the Activity's theme. (Themes whose parent theme is already set to the onboarding theme do not need to set the onboardingTheme attribute; if set, it will be ignored.) onboardingThemeonboardingHeaderStyleonboardingTitleStyleonboardingDescriptionStyleonboardingNavigatorContainerStyleonboardingPageIndicatorStyleonboardingStartButtonStyleonboardingLogoStyle

Summary

Public constructors

Public functions

@ColorInt Int

Returns the background color of the arrow if it's set through setArrowBackgroundColor.

@ColorInt Int

Returns the color of the arrow if it's set through setArrowColor.

@ColorInt Int

Returns the text color of DescriptionView if it's set through setDescriptionViewTextColor.

@ColorInt Int

Returns the background color of the dot if it's set through setDotBackgroundColor.

Int

Returns the resource id of the main icon.

Int

Returns the resource ID of the splash logo image.

CharSequence?

Returns the start button text if it's set through setStartButtonText}.

@ColorInt Int

Returns the text color of TitleView if it's set through setTitleViewTextColor.

View?
onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
)

Called to have the fragment instantiate its user interface view.

Int

Returns the theme used for styling the fragment.

Unit

Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance if its process is restarted.

Unit
onViewCreated(view: View, savedInstanceState: Bundle?)

Called immediately after onCreateView has returned, but before any saved state has been restored in to the view.

Unit

Sets the background color of the arrow.

Unit

Sets the color of the arrow.

Unit

Sets the text color for DescriptionView.

Unit

Sets the background color of the dots.

Unit
setIconResouceId(resourceId: Int)

Sets the resource id for the main icon.

Unit

Sets the resource ID of the splash logo image.

Unit

Sets the text on the start button text.

Unit

Sets the text color for TitleView.

Protected functions

Int

Returns the index of the current page.

abstract Int

Returns the page count.

abstract CharSequence?
getPageDescription(pageIndex: Int)

Returns the description of the given page.

abstract CharSequence?
getPageTitle(pageIndex: Int)

Returns the title of the given page.

Boolean

Returns whether the logo enter animation is finished.

Unit

Navigates to the next page.

Unit

Navigates to the previous page.

abstract View?

Called to have the inherited class create background view.

abstract View?
onCreateContentView(inflater: LayoutInflater, container: ViewGroup)

Called to have the inherited class create content view.

Animator

Provides the entry animation for description view.

Animator?

Called to have the inherited class create its enter animation.

abstract View?

Called to have the inherited class create foreground view.

Animator?

Called to have the inherited class create its own logo animation.

Animator

Provides the entry animation for title view.

Unit

Called when the onboarding flow finishes.

Unit

Called immediately after the logo animation is complete or no logo animation is specified.

Unit
onPageChanged(newPage: Int, previousPage: Int)

Called when the page has been changed.

Unit

Called to start entrance transition.

Inherited functions

From androidx.activity.result.ActivityResultCaller
abstract ActivityResultLauncher<I!>!
<I, O> registerForActivityResult(
    contract: ActivityResultContract<I!, O!>!,
    callback: ActivityResultCallback<O!>!
)

Register a request to start an activity for result, designated by the given contract.

From android.content.ComponentCallbacks
From androidx.fragment.app.Fragment
Unit
dump(
    prefix: String,
    fd: FileDescriptor?,
    writer: PrintWriter,
    args: Array<String!>?
)

Print the Fragments's state into the given stream.

Boolean
equals(o: Any?)

Subclasses can not override equals().

FragmentActivity?

Return the FragmentActivity this fragment is currently associated with.

Boolean

Returns whether the the exit transition and enter transition overlap or not.

Boolean

Returns whether the the return transition and reenter transition overlap or not.

Bundle?

Return the arguments supplied when the fragment was instantiated, if any.

FragmentManager

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

Context?

Return the Context this fragment is currently associated with.

CreationExtras

Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.

ViewModelProvider.Factory

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

Any?

Returns the Transition that will be used to move Views into the initial scene.

Any?

Returns the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.

FragmentManager?

This function is deprecated.

This has been removed in favor of getParentFragmentManager() which throws an IllegalStateException if the FragmentManager is null.

Any?

Return the host object of this fragment.

Int

Return the identifier this fragment is known by.

LayoutInflater

Returns the cached LayoutInflater used to inflate Views of this Fragment.

Lifecycle

Returns the Lifecycle of the provider.

LoaderManager

This function is deprecated.

Use LoaderManager.getInstance(this).

Fragment?

Returns the parent Fragment containing this Fragment.

FragmentManager

Return the FragmentManager for interacting with fragments associated with this fragment's activity.

Any?

Returns the Transition that will be used to move Views in to the scene when returning due to popping a back stack.

Resources

Return requireActivity().getResources().

Boolean

This function is deprecated.

Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.

Any?

Returns the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.

SavedStateRegistry

The SavedStateRegistry owned by this SavedStateRegistryOwner

Any?

Returns the Transition that will be used for shared elements transferred into the content Scene.

Any?

Return the Transition that will be used for shared elements transferred back during a pop of the back stack.

String

Return a localized string from the application's package's default string table.

String
getString(resId: @StringRes Int, formatArgs: Array<Any!>?)

Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in java.util.Formatter and format.

String?

Get the tag name of the fragment, if specified.

Fragment?

This function is deprecated.

Instead of using a target fragment to pass results, use setFragmentResult to deliver results to FragmentResultListener instances registered by other fragments via setFragmentResultListener.

Int

This function is deprecated.

When using the target fragment replacement of setFragmentResultListener and setFragmentResult, consider using setArguments to pass a requestKey if you need to support dynamic request keys.

CharSequence

Return a localized, styled CharSequence from the application's package's default string table.

Boolean

This function is deprecated.

Use setMaxLifecycle instead.

View?

Get the root view for the fragment's layout (the one returned by onCreateView), if provided.

LifecycleOwner

Get a LifecycleOwner that represents the Fragment's View lifecycle.

LiveData<LifecycleOwner!>

Retrieve a LiveData which allows you to observe the lifecycle of the Fragment's View.

ViewModelStore

Returns the ViewModelStore associated with this Fragment

Int

Subclasses can not override hashCode().

java-static Fragment
instantiate(context: Context, fname: String)

This function is deprecated.

Use getFragmentFactory and instantiate

java-static Fragment
instantiate(context: Context, fname: String, args: Bundle?)

This function is deprecated.

Use getFragmentFactory and instantiate, manually calling setArguments on the returned Fragment.

Boolean

Return true if the fragment is currently added to its activity.

Boolean

Return true if the fragment has been explicitly detached from the UI.

Boolean

Return true if the fragment has been hidden.

Boolean

Return true if the layout is included as part of an activity view hierarchy via the tag.

Boolean

Return true if this fragment is currently being removed from its activity.

Boolean

Return true if the fragment is in the resumed state.

Boolean

Returns true if this fragment is added and its state has already been saved by its host.

Boolean

Return true if the fragment is currently visible to the user.

Unit

This function is deprecated.

use onViewCreated for code touching the view created by onCreateView and onCreate for other initialization.

Unit
onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit

This function is deprecated.

See onAttach.

Unit

Called when a fragment is first attached to its context.

Unit

This function is deprecated.

The responsibility for listening for fragments being attached has been moved to FragmentManager.

Unit
Boolean

This hook is called whenever an item in a context menu is selected.

Unit
@MainThread
@CallSuper
onCreate(savedInstanceState: Bundle?)

Called to do initial creation of a fragment.

Animation?
@MainThread
onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int)

Called when a fragment loads an animation.

Animator?
@MainThread
onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int)

Called when a fragment loads an animator.

Unit
@MainThread
onCreateContextMenu(
    menu: ContextMenu,
    v: View,
    menuInfo: ContextMenu.ContextMenuInfo?
)

Called when a context menu for the view is about to be shown.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit

Called when the fragment is no longer in use.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit

Called when the view previously created by onCreateView has been detached from the fragment.

Unit

Called when the fragment is no longer attached to its activity.

LayoutInflater
onGetLayoutInflater(savedInstanceState: Bundle?)

Returns the LayoutInflater used to inflate Views of this Fragment.

Unit

Called when the hidden state (as returned by isHidden of the fragment or another fragment in its hierarchy has changed.

Unit
@UiThread
@CallSuper
onInflate(
    activity: Activity,
    attrs: AttributeSet,
    savedInstanceState: Bundle?
)

This function is deprecated.

See onInflate.

Unit
@UiThread
@CallSuper
onInflate(
    context: Context,
    attrs: AttributeSet,
    savedInstanceState: Bundle?
)

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.

Unit
Unit
onMultiWindowModeChanged(isInMultiWindowMode: Boolean)

Called when the Fragment's activity changes from fullscreen mode to multi-window mode and visa-versa.

Boolean

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit

Called when the Fragment is no longer resumed.

Unit
onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)

Called by the system when the activity changes to and from picture-in-picture mode.

Unit

This function is deprecated.

androidx.activity.ComponentActivity now implements MenuHost, an interface that allows any component, including your activity itself, to add menu items by calling addMenuProvider without forcing all components through this single method override.

Unit
@MainThread
onPrimaryNavigationFragmentChanged(
    isPrimaryNavigationFragment: Boolean
)

Callback for when the primary navigation state of this Fragment has changed.

Unit
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>,
    grantResults: IntArray
)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit

Called when the fragment is visible to the user and actively running.

Unit

Called when the Fragment is visible to the user.

Unit

Called when the Fragment is no longer started.

Unit

Called when all saved state has been restored into the view hierarchy of the fragment.

Unit

Postpone the entering Fragment transition until startPostponedEnterTransition or executePendingTransactions has been called.

Unit
postponeEnterTransition(duration: Long, timeUnit: TimeUnit)

Postpone the entering Fragment transition for a given amount of time and then call startPostponedEnterTransition.

ActivityResultLauncher<I!>
@MainThread
<I, O> registerForActivityResult(
    contract: ActivityResultContract<I!, O!>,
    callback: ActivityResultCallback<O!>
)

Register a request to start an activity for result, designated by the given contract.

ActivityResultLauncher<I!>
@MainThread
<I, O> registerForActivityResult(
    contract: ActivityResultContract<I!, O!>,
    registry: ActivityResultRegistry,
    callback: ActivityResultCallback<O!>
)

Register a request to start an activity for result, designated by the given contract.

Unit

Registers a context menu to be shown for the given view (multiple views can show the context menu).

Unit
requestPermissions(permissions: Array<String!>, requestCode: Int)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

FragmentActivity

Return the FragmentActivity this fragment is currently associated with.

Bundle

Return the arguments supplied when the fragment was instantiated.

Context

Return the Context this fragment is currently associated with.

FragmentManager

This function is deprecated.

This has been renamed to getParentFragmentManager() to make it clear that you are accessing the FragmentManager that contains this Fragment and not the FragmentManager associated with child Fragments.

Any

Return the host object of this fragment.

Fragment

Returns the parent Fragment containing this Fragment.

View

Get the root view for the fragment's layout (the one returned by onCreateView).

Unit

Sets whether the the exit transition and enter transition overlap or not.

Unit

Sets whether the the return transition and reenter transition overlap or not.

Unit

Supply the construction arguments for this fragment.

Unit

When custom transitions are used with Fragments, the enter transition callback is called when this Fragment is attached or detached when not popping the back stack.

Unit
setEnterTransition(transition: Any?)

Sets the Transition that will be used to move Views into the initial scene.

Unit

When custom transitions are used with Fragments, the exit transition callback is called when this Fragment is attached or detached when popping the back stack.

Unit
setExitTransition(transition: Any?)

Sets the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.

Unit

This function is deprecated.

This method is no longer needed when using a MenuProvider to provide a Menu to your activity, which replaces onCreateOptionsMenu as the recommended way to provide a consistent, optionally Lifecycle-aware, and modular way to handle menu creation and item selection.

Unit

Set the initial saved state that this Fragment should restore itself from when first being constructed, as returned by FragmentManager.saveFragmentInstanceState.

Unit
setMenuVisibility(menuVisible: Boolean)

Set a hint for whether this fragment's menu should be visible.

Unit
setReenterTransition(transition: Any?)

Sets the Transition that will be used to move Views in to the scene when returning due to popping a back stack.

Unit

This function is deprecated.

Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.

Unit
setReturnTransition(transition: Any?)

Sets the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.

Unit

Sets the Transition that will be used for shared elements transferred into the content Scene.

Unit

Sets the Transition that will be used for shared elements transferred back during a pop of the back stack.

Unit
setTargetFragment(fragment: Fragment?, requestCode: Int)

This function is deprecated.

Instead of using a target fragment to pass results, the fragment requesting a result should use setFragmentResultListener to register a FragmentResultListener with a requestKey using its parent fragment manager.

Unit
setUserVisibleHint(isVisibleToUser: Boolean)

This function is deprecated.

If you are manually calling this method, use setMaxLifecycle instead.

Boolean

Gets whether you should show UI with rationale before requesting a permission.

Unit

Call startActivity from the fragment's containing Activity.

Unit
startActivity(intent: Intent, options: Bundle?)

Call startActivity from the fragment's containing Activity.

Unit
startActivityForResult(intent: Intent, requestCode: Int)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit
startActivityForResult(intent: Intent, requestCode: Int, options: Bundle?)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit
startIntentSenderForResult(
    intent: IntentSender,
    requestCode: Int,
    fillInIntent: Intent?,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int,
    options: Bundle?
)

This function is deprecated.

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

Unit

Begin postponed transitions after postponeEnterTransition was called.

String
Unit

Prevents a context menu to be shown for the given view.

From androidx.lifecycle.HasDefaultViewModelProviderFactory
CreationExtras!

Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.

abstract ViewModelProvider.Factory!

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

From androidx.lifecycle.LifecycleOwner
abstract Lifecycle!

Returns the Lifecycle of the provider.

From androidx.savedstate.SavedStateRegistryOwner
abstract SavedStateRegistry!

The SavedStateRegistry owned by this SavedStateRegistryOwner

From android.view.View.OnCreateContextMenuListener
abstract Unit
onCreateContextMenu(
    p: ContextMenu!,
    p1: View!,
    p2: ContextMenu.ContextMenuInfo!
)
From androidx.lifecycle.ViewModelStoreOwner

Public constructors

OnboardingSupportFragment

Added in 1.1.0
OnboardingSupportFragment()

Public functions

getArrowBackgroundColor

Added in 1.1.0
fun getArrowBackgroundColor(): @ColorInt Int

Returns the background color of the arrow if it's set through setArrowBackgroundColor. If no color was set, transparent is returned.

getArrowColor

Added in 1.1.0
fun getArrowColor(): @ColorInt Int

Returns the color of the arrow if it's set through setArrowColor. If no color was set, transparent is returned.

getDescriptionViewTextColor

Added in 1.1.0
fun getDescriptionViewTextColor(): @ColorInt Int

Returns the text color of DescriptionView if it's set through setDescriptionViewTextColor. If no color was set, transparent is returned.

getDotBackgroundColor

Added in 1.1.0
fun getDotBackgroundColor(): @ColorInt Int

Returns the background color of the dot if it's set through setDotBackgroundColor. If no color was set, transparent is returned.

getIconResourceId

Added in 1.1.0
fun getIconResourceId(): Int

Returns the resource id of the main icon.

getLogoResourceId

Added in 1.1.0
fun getLogoResourceId(): Int

Returns the resource ID of the splash logo image.

Returns
Int

The resource ID of the splash logo image.

getStartButtonText

Added in 1.1.0
fun getStartButtonText(): CharSequence?

Returns the start button text if it's set through setStartButtonText}. If no string was set, null is returned.

getTitleViewTextColor

Added in 1.1.0
fun getTitleViewTextColor(): @ColorInt Int

Returns the text color of TitleView if it's set through setTitleViewTextColor. If no color was set, transparent is returned.

onCreateView

fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View?

Called to have the fragment instantiate its user interface view. This is optional, and non-graphical fragments can return null. This will be called between onCreate and onViewCreated.

A default View can be returned by calling Fragment in your constructor. Otherwise, this method returns null.

It is recommended to only inflate the layout in this method and move logic that operates on the returned View to onViewCreated.

If you return a View from here, you will later be called in onDestroyView when the view is being released.

Parameters
inflater: LayoutInflater

The LayoutInflater object that can be used to inflate any views in the fragment,

container: ViewGroup?

If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view.

savedInstanceState: Bundle?

If non-null, this fragment is being re-constructed from a previous saved state as given here.

Returns
View?

Return the View for the fragment's UI, or null.

onProvideTheme

Added in 1.1.0
fun onProvideTheme(): Int

Returns the theme used for styling the fragment. The default returns -1, indicating that the host Activity's theme should be used.

Returns
Int

The theme resource ID of the theme to use in this fragment, or -1 to use the host Activity's theme.

onSaveInstanceState

fun onSaveInstanceState(outState: Bundle): Unit

Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance if its process is restarted. If a new instance of the fragment later needs to be created, the data you place in the Bundle here will be available in the Bundle given to onCreate, onCreateView, and onViewCreated.

This corresponds to Activity.onSaveInstanceState(Bundle) and most of the discussion there applies here as well. Note however: this method may be called at any time before onDestroy. There are many situations where a fragment may be mostly torn down (such as when placed on the back stack with no UI showing), but its state will not be saved until its owning activity actually needs to save its state.

Parameters
outState: Bundle

Bundle in which to place your saved state.

onViewCreated

fun onViewCreated(view: View, savedInstanceState: Bundle?): Unit

Called immediately after onCreateView has returned, but before any saved state has been restored in to the view. This gives subclasses a chance to initialize themselves once they know their view hierarchy has been completely created. The fragment's view hierarchy is not however attached to its parent at this point.

Parameters
view: View

The View returned by onCreateView.

savedInstanceState: Bundle?

If non-null, this fragment is being re-constructed from a previous saved state as given here.

setArrowBackgroundColor

Added in 1.1.0
fun setArrowBackgroundColor(color: @ColorInt Int): Unit

Sets the background color of the arrow. If not set, the default color from attr PagingIndicator_arrowBgColor in the theme will be used.

Parameters
color: @ColorInt Int

the color to use for arrow background

setArrowColor

Added in 1.1.0
fun setArrowColor(color: @ColorInt Int): Unit

Sets the color of the arrow. This color will supersede the color set in the theme attribute PagingIndicator_arrowColor if provided. If none of these two are set, the arrow will have its original bitmap color.

Parameters
color: @ColorInt Int

the color to use for arrow background

setDescriptionViewTextColor

Added in 1.1.0
fun setDescriptionViewTextColor(color: @ColorInt Int): Unit

Sets the text color for DescriptionView. If not set, the default textColor set in style referenced by attr onboardingDescriptionStyle will be used.

Parameters
color: @ColorInt Int

the color to use as the text color for DescriptionView

setDotBackgroundColor

Added in 1.1.0
fun setDotBackgroundColor(color: @ColorInt Int): Unit

Sets the background color of the dots. If not set, the default color from attr PagingIndicator_dotBgColor in the theme will be used.

Parameters
color: @ColorInt Int

the color to use for dot backgrounds

setIconResouceId

Added in 1.1.0
fun setIconResouceId(resourceId: Int): Unit

Sets the resource id for the main icon.

setLogoResourceId

Added in 1.1.0
fun setLogoResourceId(id: Int): Unit

Sets the resource ID of the splash logo image. If the logo resource id set, the default logo splash animation will be played.

Parameters
id: Int

The resource ID of the logo image.

setStartButtonText

Added in 1.1.0
fun setStartButtonText(text: CharSequence?): Unit

Sets the text on the start button text. If not set, the default text set in LeanbackOnboardingTheme_onboardingStartButtonStyle will be used.

Parameters
text: CharSequence?

the start button text

setTitleViewTextColor

Added in 1.1.0
fun setTitleViewTextColor(color: @ColorInt Int): Unit

Sets the text color for TitleView. If not set, the default textColor set in style referenced by attr onboardingTitleStyle will be used.

Parameters
color: @ColorInt Int

the color to use as the text color for TitleView

Protected functions

getCurrentPageIndex

Added in 1.1.0
protected fun getCurrentPageIndex(): Int

Returns the index of the current page.

Returns
Int

The index of the current page.

getPageCount

Added in 1.1.0
protected abstract fun getPageCount(): Int

Returns the page count.

Returns
Int

The page count.

getPageDescription

Added in 1.1.0
protected abstract fun getPageDescription(pageIndex: Int): CharSequence?

Returns the description of the given page.

Parameters
pageIndex: Int

The page index.

Returns
CharSequence?

The description of the page.

getPageTitle

Added in 1.1.0
protected abstract fun getPageTitle(pageIndex: Int): CharSequence?

Returns the title of the given page.

Parameters
pageIndex: Int

The page index.

Returns
CharSequence?

The title of the page.

isLogoAnimationFinished

Added in 1.1.0
protected fun isLogoAnimationFinished(): Boolean

Returns whether the logo enter animation is finished.

Returns
Boolean

true if the logo enter transition is finished, false otherwise

moveToNextPage

Added in 1.1.0
protected fun moveToNextPage(): Unit

Navigates to the next page.

moveToPreviousPage

Added in 1.1.0
protected fun moveToPreviousPage(): Unit

Navigates to the previous page.

onCreateBackgroundView

Added in 1.1.0
protected abstract fun onCreateBackgroundView(inflater: LayoutInflater, container: ViewGroup): View?

Called to have the inherited class create background view. This is optional and the fragment which doesn't have the background view can return null. This is called inside onCreateView.

Parameters
inflater: LayoutInflater

The LayoutInflater object that can be used to inflate the views,

container: ViewGroup

The parent view that the additional views are attached to.The fragment should not add the view by itself.

Returns
View?

The background view for the onboarding screen, or null.

onCreateContentView

Added in 1.1.0
protected abstract fun onCreateContentView(inflater: LayoutInflater, container: ViewGroup): View?

Called to have the inherited class create content view. This is optional and the fragment which doesn't have the content view can return null. This is called inside onCreateView.

The content view would be located at the center of the screen.

Parameters
inflater: LayoutInflater

The LayoutInflater object that can be used to inflate the views,

container: ViewGroup

The parent view that the additional views are attached to.The fragment should not add the view by itself.

Returns
View?

The content view for the onboarding screen, or null.

onCreateDescriptionAnimator

Added in 1.1.0
protected fun onCreateDescriptionAnimator(): Animator

Provides the entry animation for description view. This allows users to override the default fade and slide animation. Returning null will disable the animation.

onCreateEnterAnimation

Added in 1.1.0
protected fun onCreateEnterAnimation(): Animator?

Called to have the inherited class create its enter animation. The start animation runs after logo animation ends.

Returns
Animator?

The Animator object which runs the page enter animation.

onCreateForegroundView

Added in 1.1.0
protected abstract fun onCreateForegroundView(inflater: LayoutInflater, container: ViewGroup): View?

Called to have the inherited class create foreground view. This is optional and the fragment which doesn't need the foreground view can return null. This is called inside onCreateView.

This foreground view would have the highest z-order.

Parameters
inflater: LayoutInflater

The LayoutInflater object that can be used to inflate the views,

container: ViewGroup

The parent view that the additional views are attached to.The fragment should not add the view by itself.

Returns
View?

The foreground view for the onboarding screen, or null.

onCreateLogoAnimation

Added in 1.1.0
protected fun onCreateLogoAnimation(): Animator?

Called to have the inherited class create its own logo animation.

This is called only if the logo image resource ID is not set by setLogoResourceId. If this returns null, the logo animation is skipped.

Returns
Animator?

The Animator object which runs the logo animation.

onCreateTitleAnimator

Added in 1.1.0
protected fun onCreateTitleAnimator(): Animator

Provides the entry animation for title view. This allows users to override the default fade and slide animation. Returning null will disable the animation.

onFinishFragment

Added in 1.1.0
protected fun onFinishFragment(): Unit

Called when the onboarding flow finishes.

onLogoAnimationFinished

Added in 1.1.0
protected fun onLogoAnimationFinished(): Unit

Called immediately after the logo animation is complete or no logo animation is specified. This method can also be called when the activity is recreated, i.e. when no logo animation are performed. By default, this method will hide the logo view and start the entrance animation for this fragment. Overriding subclasses can provide their own data loading logic as to when the entrance animation should be executed.

onPageChanged

Added in 1.1.0
protected fun onPageChanged(newPage: Int, previousPage: Int): Unit

Called when the page has been changed.

Parameters
newPage: Int

The new page.

previousPage: Int

The previous page.

startEnterAnimation

Added in 1.1.0
protected fun startEnterAnimation(force: Boolean): Unit

Called to start entrance transition. This can be called by subclasses when the logo animation and data loading is complete. If force flag is set to false, it will only start the animation if it's not already done yet. Otherwise, it will always start the enter animation. In both cases, the logo view will hide and the rest of fragment views become visible after this call.

Parameters
force: Boolean

true if enter animation has to be performed regardless of whether it's been done in the past, false otherwise