# TitleViewAdapter

# TitleViewAdapter

Artifact:[androidx.leanback:leanback](https://developer.android.com/jetpack/androidx/releases/leanback)  
[View Source](https://cs.android.com/search?q=file:androidx/leanback/widget/TitleViewAdapter.java+class:androidx.leanback.widget.TitleViewAdapter)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/leanback/widget/TitleViewAdapter "View this page in Java")

<br />

```
abstract class TitleViewAdapter
```

<br />

*** ** * ** ***

This class allows a customized widget class to implement[TitleViewAdapter.Provider](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter.Provider)and expose[TitleViewAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter)methods to containing fragment (e.g. BrowseFragment or DetailsFragment). The title view must have a search orb view ([getSearchAffordanceView](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#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 types                                                                                                                                                        |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interface `[TitleViewAdapter.Provider](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter.Provider) Interface to be implemented by a customized widget class to implement[TitleViewAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter). |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [BRANDING_VIEW_VISIBLE](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#BRANDING_VIEW_VISIBLE())` = 2` |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [FULL_VIEW_VISIBLE](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#FULL_VIEW_VISIBLE())` = 6`         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SEARCH_VIEW_VISIBLE](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#SEARCH_VIEW_VISIBLE())` = 4`     |

|                                                       ### Public constructors                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------|
| [TitleViewAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#TitleViewAdapter())`()` |

|                                                  ### Public functions                                                   |
|-------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`!`                          | [getBadgeDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#getBadgeDrawable())`()` Returns the badge drawable.                                                                                                                                                                                                                                                                                                                                                           |
| [SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors)`!` | [getSearchAffordanceColors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#getSearchAffordanceColors())`()` Returns the[androidx.leanback.widget.SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors)used to draw the search affordance.                                                                                                                                                                         |
| `abstract `[View](https://developer.android.com/reference/android/view/View.html)`!`                                    | [getSearchAffordanceView](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#getSearchAffordanceView())`()` Returns the view for the search affordance.                                                                                                                                                                                                                                                                                                                             |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!`                       | [getTitle](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#getTitle())`()` Returns the title text.                                                                                                                                                                                                                                                                                                                                                                               |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                           | [setAnimationEnabled](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#setAnimationEnabled(boolean))`(enable: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Enables or disables any view animations.                                                                                                                                                                                                                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                           | [setBadgeDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#setBadgeDrawable(android.graphics.drawable.Drawable))`(drawable: `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`!)` Sets the badge drawable.                                                                                                                                                                                                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                           | [setOnSearchClickedListener](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#setOnSearchClickedListener(android.view.View.OnClickListener))`(listener: `[View.OnClickListener](https://developer.android.com/reference/android/view/View.OnClickListener.html)`!)` Sets a click listener for the search affordance view.                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                           | [setSearchAffordanceColors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#setSearchAffordanceColors(androidx.leanback.widget.SearchOrbView.Colors))`(colors: `[SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors)`)` Sets the[androidx.leanback.widget.SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors)used to draw the search affordance. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                           | [setTitle](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#setTitle(java.lang.CharSequence))`(titleText: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!)` Sets the title text.                                                                                                                                                                                                                                                |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                           | [updateComponentsVisibility](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#updateComponentsVisibility(int))`(flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Based on the flag, it updates the visibility of the individual components - Branding views (badge drawable and/or title) and search affordance view.                                                                                                                       |

## Constants

### BRANDING_VIEW_VISIBLE

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
const val BRANDING_VIEW_VISIBLE = 2: Int
```  

### FULL_VIEW_VISIBLE

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
const val FULL_VIEW_VISIBLE = 6: Int
```  

### SEARCH_VIEW_VISIBLE

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
const val SEARCH_VIEW_VISIBLE = 4: Int
```  

## Public constructors

### TitleViewAdapter

Added in 1.1.0  

```
TitleViewAdapter()
```  

## Public functions

### getBadgeDrawable

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun getBadgeDrawable(): Drawable!
```

Returns the badge drawable.  

|                                            Returns                                             |
|------------------------------------------------------------------------------------------------|---------------------|
| [Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`!` | The badge drawable. |

### getSearchAffordanceColors

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun getSearchAffordanceColors(): SearchOrbView.Colors!
```

Returns the[androidx.leanback.widget.SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors)used to draw the search affordance.  

|                                                         Returns                                                         |
|-------------------------------------------------------------------------------------------------------------------------|----------------------------------------|
| [SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors)`!` | Colors used to draw search affordance. |

### getSearchAffordanceView

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
abstract fun getSearchAffordanceView(): View!
```

Returns the view for the search affordance.  

|                                  Returns                                  |
|---------------------------------------------------------------------------|---------------------------------|
| [View](https://developer.android.com/reference/android/view/View.html)`!` | The view for search affordance. |

### getTitle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun getTitle(): CharSequence!
```

Returns the title text.  

|                                              Returns                                              |
|---------------------------------------------------------------------------------------------------|-----------------|
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!` | The title text. |

### setAnimationEnabled

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True to enable animation, false otherwise. |

### setBadgeDrawable

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun setBadgeDrawable(drawable: Drawable!): Unit
```

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

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|------------------------------------------|
| `drawable: `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`!` | The badge drawable to set on title view. |

### setOnSearchClickedListener

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun setOnSearchClickedListener(listener: View.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](https://developer.android.com/reference/android/view/View.OnClickListener.html#onClick(android.view.View))method will be invoked when the user clicks on the search element.  

|                                                      Parameters                                                       |
|-----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| `listener: `[View.OnClickListener](https://developer.android.com/reference/android/view/View.OnClickListener.html)`!` | The listener to call when the search element is clicked. |

### setSearchAffordanceColors

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun setSearchAffordanceColors(colors: SearchOrbView.Colors): Unit
```

Sets the[androidx.leanback.widget.SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors)used to draw the search affordance.  

|                                                           Parameters                                                           |
|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|
| `colors: `[SearchOrbView.Colors](https://developer.android.com/reference/kotlin/androidx/leanback/widget/SearchOrbView.Colors) | Colors used to draw search affordance. |

### setTitle

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
fun setTitle(titleText: CharSequence!): Unit
```

Sets the title text.  

|                                                   Parameters                                                   |
|----------------------------------------------------------------------------------------------------------------|---------------------------|
| `titleText: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!` | The text to set as title. |

### updateComponentsVisibility

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | integer representing the visibility of TitleView components. |

|                                                                 See also                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|---|
| [BRANDING_VIEW_VISIBLE](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#BRANDING_VIEW_VISIBLE()) |   |
| [SEARCH_VIEW_VISIBLE](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#SEARCH_VIEW_VISIBLE())     |   |
| [FULL_VIEW_VISIBLE](https://developer.android.com/reference/kotlin/androidx/leanback/widget/TitleViewAdapter#FULL_VIEW_VISIBLE())         |   |