Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

TitleViewAdapter

abstract class TitleViewAdapter
kotlin.Any
   ↳ androidx.leanback.widget.TitleViewAdapter

This class allows a customized widget class to implement TitleViewAdapter.Provider and expose TitleViewAdapter methods to containing fragment (e.g. BrowseFragment or DetailsFragment). The title view must have a search orb view (getSearchAffordanceView() aligned to start and can typically have a branding Drawable and or title text aligned to end. The branding part is fully open to customization: not necessary to be a drawable or text.

Summary

Nested classes
abstract

Interface to be implemented by a customized widget class to implement TitleViewAdapter.

Constants
static Int

static Int

static Int

Public constructors

This class allows a customized widget class to implement TitleViewAdapter.Provider and expose TitleViewAdapter methods to containing fragment (e.g. BrowseFragment or DetailsFragment).

Public methods
open SearchOrbView.Colors!

Returns the androidx.leanback.widget.SearchOrbView.Colors used to draw the search affordance.

open Unit

Sets the badge drawable.

abstract View!

Returns the view for the search affordance.

open Unit

Sets the androidx.leanback.widget.SearchOrbView.Colors used to draw the search affordance.

open Unit

Sets a click listener for the search affordance view.

open Unit

Based on the flag, it updates the visibility of the individual components - Branding views (badge drawable and/or title) and search affordance view.

open Unit

Enables or disables any view animations.

open Unit
setTitle(titleText: CharSequence!)

Sets the title text.

open CharSequence!

Returns the title text.

open Drawable!

Returns the badge drawable.

Constants

BRANDING_VIEW_VISIBLE

static val BRANDING_VIEW_VISIBLE: Int
Value: 0x02

SEARCH_VIEW_VISIBLE

static val SEARCH_VIEW_VISIBLE: Int
Value: 0x04

FULL_VIEW_VISIBLE

static val FULL_VIEW_VISIBLE: Int
Value: BRANDING_VIEW_VISIBLE | SEARCH_VIEW_VISIBLE

Public constructors

<init>

TitleViewAdapter()

This class allows a customized widget class to implement TitleViewAdapter.Provider and expose TitleViewAdapter methods to containing fragment (e.g. BrowseFragment or DetailsFragment). The title view must have a search orb view (getSearchAffordanceView() aligned to start and can typically have a branding Drawable and or title text aligned to end. The branding part is fully open to customization: not necessary to be a drawable or text.

Public methods

getSearchAffordanceColors

open fun getSearchAffordanceColors(): SearchOrbView.Colors!

Returns the androidx.leanback.widget.SearchOrbView.Colors used to draw the search affordance.

Return
SearchOrbView.Colors!: Colors used to draw search affordance.

setBadgeDrawable

open fun setBadgeDrawable(drawable: Drawable!): Unit

Sets the badge drawable. If non-null, the drawable is displayed instead of the title text.

Parameters
drawable Drawable!: The badge drawable to set on title view.

getSearchAffordanceView

abstract fun getSearchAffordanceView(): View!

Returns the view for the search affordance.

Return
View!: The view for search affordance.

setSearchAffordanceColors

open fun setSearchAffordanceColors(colors: SearchOrbView.Colors!): Unit

Sets the androidx.leanback.widget.SearchOrbView.Colors used to draw the search affordance.

Parameters
colors SearchOrbView.Colors!: Colors used to draw search affordance.

setOnSearchClickedListener

open fun setOnSearchClickedListener(listener: OnClickListener!): Unit

Sets a click listener for the search affordance view.

The presence of a listener will change the visibility of the search affordance in the fragment title. When set to non-null, the title will contain an element that a user may click to begin a search.

The listener's onClick method will be invoked when the user clicks on the search element.

Parameters
listener OnClickListener!: The listener to call when the search element is clicked.

updateComponentsVisibility

open fun updateComponentsVisibility(flags: Int): Unit

Based on the flag, it updates the visibility of the individual components - Branding views (badge drawable and/or title) and search affordance view.

Parameters
flags Int: integer representing the visibility of TitleView components.

setAnimationEnabled

open fun setAnimationEnabled(enable: Boolean): Unit

Enables or disables any view animations. This method is called to save CPU cycle for example stop search view breathing animation when containing fragment is paused.

Parameters
enable Boolean: True to enable animation, false otherwise.

setTitle

open fun setTitle(titleText: CharSequence!): Unit

Sets the title text.

Parameters
titleText CharSequence!: The text to set as title.

getTitle

open fun getTitle(): CharSequence!

Returns the title text.

Return
CharSequence!: The title text.

getBadgeDrawable

open fun getBadgeDrawable(): Drawable!

Returns the badge drawable.

Return
Drawable!: The badge drawable.