# DetailsSupportFragmentBackgroundController

# DetailsSupportFragmentBackgroundController

Artifact:[androidx.leanback:leanback](https://developer.android.com/jetpack/androidx/releases/leanback)  
[View Source](https://cs.android.com/search?q=file:androidx/leanback/app/DetailsSupportFragmentBackgroundController.java+class:androidx.leanback.app.DetailsSupportFragmentBackgroundController)  
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/app/DetailsSupportFragmentBackgroundController "View this page in Java")

<br />

```
class DetailsSupportFragmentBackgroundController
```

<br />

*** ** * ** ***

Controller for DetailsSupportFragment parallax background and embedded video play.

The parallax background drawable is made of two parts: cover drawable (by default[FitWidthBitmapDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/graphics/FitWidthBitmapDrawable)) above the details overview row and bottom drawable (by default[ColorDrawable](https://developer.android.com/reference/android/graphics/drawable/ColorDrawable.html)) below the details overview row. While vertically scrolling rows, the size of cover drawable and bottom drawable will be updated and the cover drawable will by default perform a parallax shift using[PROPERTY_VERTICAL_OFFSET](https://developer.android.com/reference/kotlin/androidx/leanback/graphics/FitWidthBitmapDrawable#PROPERTY_VERTICAL_OFFSET()).  

```kotlin
       ***************************
       *      Cover Drawable     *
       * (FitWidthBitmapDrawable)*
       *                         *
       ***************************
       *    DetailsOverviewRow   *
       *                         *
       ***************************
       *     Bottom Drawable     *
       *      (ColorDrawable)    *
       *         Related         *
       *         Content         *
       ***************************
```
Both parallax background drawable and embedded video play are optional. App must call[enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax())and/or[setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue))explicitly. The PlaybackGlue is automatically[play](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue#play())when fragment starts and[pause](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue#pause())when fragment stops. When video is ready to play, cover drawable will be faded out. Example:  

```kotlin
DetailsSupportFragmentBackgroundController mController = new DetailsSupportFragmentBackgroundController(this);

public void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);
    MediaPlayerGlue player = new MediaPlayerGlue(..);
    player.setUrl(...);
    mController.enableParallax();
    mController.setupVideoPlayback(player);
}

static class MyLoadBitmapTask extends ... {
    WeakReferencemFragmentRef;
    MyLoadBitmapTask(MyFragment fragment) {
        mFragmentRef = new WeakReference(fragment);
    }
    protected void onPostExecute(Bitmap bitmap) {
        MyFragment fragment = mFragmentRef.get();
        if (fragment != null) {
            fragment.mController.setCoverBitmap(bitmap);
        }
    }
}

public void onStart() {
    new MyLoadBitmapTask(this).execute(url);
}

public void onStop() {
    mController.setCoverBitmap(null);
}
```

To customize cover drawable and/or bottom drawable, app should call[enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax(android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,androidx.leanback.widget.ParallaxTarget.PropertyValuesHolderTarget)). If app supplies a custom cover Drawable, it should not call[setCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setCoverBitmap(android.graphics.Bitmap)). If app supplies a custom bottom Drawable, it should not call[setSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setSolidColor(int)).

To customize playback fragment, app should override[onCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateVideoSupportFragment())and[onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost()).

## Summary

|                                                                                                                                                                                                                                ### Public constructors                                                                                                                                                                                                                                 |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DetailsSupportFragmentBackgroundController](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#DetailsSupportFragmentBackgroundController(androidx.leanback.app.DetailsSupportFragment))`(` ` fragment: `[DetailsSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragment)`!` `)` Creates a DetailsSupportFragmentBackgroundController for a DetailsSupportFragment. |

|                                                                           ### Public functions                                                                           |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                      | [canNavigateToVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#canNavigateToVideoSupportFragment())`()` Precondition allows user navigate to video fragment using DPAD.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax())`()` Enables default parallax background using a[FitWidthBitmapDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/graphics/FitWidthBitmapDrawable)as cover drawable and[ColorDrawable](https://developer.android.com/reference/android/graphics/drawable/ColorDrawable.html)as bottom drawable.                                                                                                                                                                                                                                                                                                                                                             |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax(android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,androidx.leanback.widget.ParallaxTarget.PropertyValuesHolderTarget))`(` ` coverDrawable: `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`,` ` bottomDrawable: `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`,` ` coverDrawableParallaxTarget: `[ParallaxTarget.PropertyValuesHolderTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget)`?` `)` Enables parallax background using a custom cover drawable at top and a custom bottom drawable. |
| [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment)`!`                                                                             | [findOrCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#findOrCreateVideoSupportFragment())`()` Adds or gets fragment for rendering video in DetailsSupportFragment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`!`                                                                           | [getBottomDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#getBottomDrawable())`()` Returns the drawable at bottom.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`!`                                                                                        | [getCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#getCoverBitmap())`()` Returns Bitmap set by[setCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setCoverBitmap(android.graphics.Bitmap)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)`!`                                                                           | [getCoverDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#getCoverDrawable())`()` Returns the cover drawable at top.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                              | [getParallaxDrawableMaxOffset](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#getParallaxDrawableMaxOffset())`()` Returns Default parallax offset in pixels for bitmap moving vertically.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue)`!`                                                                   | [getPlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#getPlaybackGlue())`()` Returns current PlaybackGlue or null if not set or cleared.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `@`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [getSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#getSolidColor())`()` Returns color set by[setSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setSolidColor(int)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [PlaybackGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlueHost)`!`                                                           | [onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost())`()` Creates a PlaybackGlueHost to host PlaybackGlue.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment)`!`                                                                             | [onCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateVideoSupportFragment())`()` Creates a Fragment to host[PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [setCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setCoverBitmap(android.graphics.Bitmap))`(bitmap: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`!)` Convenient method to set Bitmap in cover drawable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [setParallaxDrawableMaxOffset](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setParallaxDrawableMaxOffset(int))`(offset: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets default parallax offset in pixels for bitmap moving vertically.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [setSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setSolidColor(int))`(color: @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Convenient method to set color in bottom drawable.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue))`(playbackGlue: `[PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue)`)` Enable video playback and set proper[PlaybackGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlueHost).                                                                                                                                                                                                                                                                                                                                                                |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [switchToRows](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#switchToRows())`()` Switch to rows fragment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [switchToVideo](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#switchToVideo())`()` Switch to video fragment, note that this method is not affected by result of[canNavigateToVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#canNavigateToVideoSupportFragment()).                                                                                                                                                                                                                                                                                                                                                                                                            |

## Public constructors

### DetailsSupportFragmentBackgroundController

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

```
DetailsSupportFragmentBackgroundController(
    fragment: DetailsSupportFragment!
)
```

Creates a DetailsSupportFragmentBackgroundController for a DetailsSupportFragment. Note that each DetailsSupportFragment can only associate with one DetailsSupportFragmentBackgroundController.  

|                                                              Parameters                                                              |
|--------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| `fragment: `[DetailsSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragment)`!` | The DetailsSupportFragment to control background and embedded video playing. |

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If fragment was already associated with another controller. |

## Public functions

### canNavigateToVideoSupportFragment

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

```
fun canNavigateToVideoSupportFragment(): Boolean
```

Precondition allows user navigate to video fragment using DPAD. Default implementation returns true if PlaybackGlue is not null. Subclass may override, e.g. only allow navigation when[isPrepared](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue#isPrepared())is true. Note this method does not block app calls[switchToVideo](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#switchToVideo()).  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True allow to navigate to video fragment. |

### enableParallax

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

```
fun enableParallax(): Unit
```

Enables default parallax background using a[FitWidthBitmapDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/graphics/FitWidthBitmapDrawable)as cover drawable and[ColorDrawable](https://developer.android.com/reference/android/graphics/drawable/ColorDrawable.html)as bottom drawable. A vertical parallax movement will be applied to the FitWidthBitmapDrawable. App may use[setSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setSolidColor(int))and[setCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setCoverBitmap(android.graphics.Bitmap))to change the content of bottom drawable and cover drawable. This method must be called before[setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue)).  

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If[setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue))was called. |

|                                                                                 See also                                                                                  |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [setCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setCoverBitmap(android.graphics.Bitmap)) |   |
| [setSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setSolidColor(int))                       |   |

### enableParallax

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

```
fun enableParallax(
    coverDrawable: Drawable,
    bottomDrawable: Drawable,
    coverDrawableParallaxTarget: ParallaxTarget.PropertyValuesHolderTarget?
): Unit
```

Enables parallax background using a custom cover drawable at top and a custom bottom drawable. This method must be called before[setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue)).  

|                                                                                            Parameters                                                                                            |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `coverDrawable: `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)                                                                                     | Custom cover drawable shown at top.[setCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setCoverBitmap(android.graphics.Bitmap))will not work if coverDrawable is not[FitWidthBitmapDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/graphics/FitWidthBitmapDrawable); in that case it's app's responsibility to set content into coverDrawable. |
| `bottomDrawable: `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)                                                                                    | Drawable shown at bottom.[setSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setSolidColor(int))will not work if bottomDrawable is not[ColorDrawable](https://developer.android.com/reference/android/graphics/drawable/ColorDrawable.html); in that case it's app's responsibility to set content of bottomDrawable.                                                      |
| `coverDrawableParallaxTarget: `[ParallaxTarget.PropertyValuesHolderTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget)`?` | Target to perform parallax effect within coverDrawable. Use null for no parallax movement effect. Example to move bitmap within FitWidthBitmapDrawable: new ParallaxTarget.PropertyValuesHolderTarget( coverDrawable, PropertyValuesHolder.ofInt( FitWidthBitmapDrawable.PROPERTY_VERTICAL_OFFSET, 0, -120))                                                                                                                                           |

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | If[setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue))was called. |

### findOrCreateVideoSupportFragment

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

```
fun findOrCreateVideoSupportFragment(): Fragment!
```

Adds or gets fragment for rendering video in DetailsSupportFragment. A subclass that overrides[onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost())should call this method to get a fragment for creating a[PlaybackGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlueHost).  

|                                           Returns                                            |
|----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment)`!` | Fragment the added or restored fragment responsible for rendering video. |

|                                                                        See also                                                                        |
|--------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost()) |   |

### getBottomDrawable

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

```
fun getBottomDrawable(): Drawable!
```

Returns the drawable at bottom. Returns null if[enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax())is not called. By default it's a[ColorDrawable](https://developer.android.com/reference/android/graphics/drawable/ColorDrawable.html).  

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

### getCoverBitmap

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

```
fun getCoverBitmap(): Bitmap!
```

Returns Bitmap set by[setCoverBitmap](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setCoverBitmap(android.graphics.Bitmap)).  

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|----------------------------|
| [Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`!` | Bitmap for cover drawable. |

### getCoverDrawable

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

```
fun getCoverDrawable(): Drawable!
```

Returns the cover drawable at top. Returns null if[enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax())is not called. By default it's a[FitWidthBitmapDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/graphics/FitWidthBitmapDrawable).  

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

### getParallaxDrawableMaxOffset

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

```
fun getParallaxDrawableMaxOffset(): Int
```

Returns Default parallax offset in pixels for bitmap moving vertically. When 0, a default value would be used.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Default parallax offset in pixels for bitmap moving vertically. |

|                                                                      See also                                                                      |
|----------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax()) |   |

### getPlaybackGlue

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

```
fun getPlaybackGlue(): PlaybackGlue!
```

Returns current PlaybackGlue or null if not set or cleared.  

|                                                Returns                                                 |
|--------------------------------------------------------------------------------------------------------|------------------------------|
| [PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue)`!` | Current PlaybackGlue or null |

### getSolidColor

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

```
fun getSolidColor(): @ColorInt Int
```

Returns color set by[setSolidColor](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setSolidColor(int)).  

|                                                                                 Returns                                                                                  |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| `@`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Solid color used for bottom drawable. |

### onCreateGlueHost

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

```
fun onCreateGlueHost(): PlaybackGlueHost!
```

Creates a PlaybackGlueHost to host PlaybackGlue. App may override this if it overrides[onCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateVideoSupportFragment()). This method must be called after calling Fragment super.onCreate(). When override this method, app may call[findOrCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#findOrCreateVideoSupportFragment())to get or create a fragment.  

|                                                    Returns                                                     |
|----------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| [PlaybackGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlueHost)`!` | A new PlaybackGlueHost to host PlaybackGlue. |

|                                                                                            See also                                                                                            |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateVideoSupportFragment())                 |   |
| [findOrCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#findOrCreateVideoSupportFragment())         |   |
| [setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue)) |   |

### onCreateVideoSupportFragment

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

```
fun onCreateVideoSupportFragment(): Fragment!
```

Creates a Fragment to host[PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue). Returns a new[VideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/VideoSupportFragment)by default. App may override and return a different fragment and it also must override[onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost()).  

|                                           Returns                                            |
|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Fragment](https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment)`!` | A new fragment used in[onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost()). |

|                                                                                            See also                                                                                            |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost())                                         |   |
| [setupVideoPlayback](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#setupVideoPlayback(androidx.leanback.media.PlaybackGlue)) |   |

### setCoverBitmap

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

```
fun setCoverBitmap(bitmap: Bitmap!): Unit
```

Convenient method to set Bitmap in cover drawable. If app is not using default[FitWidthBitmapDrawable](https://developer.android.com/reference/kotlin/androidx/leanback/graphics/FitWidthBitmapDrawable), app should not use this method It's safe to call setCoverBitmap() before calling[enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax()).  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|-------------------------|
| `bitmap: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`!` | bitmap to set as cover. |

### setParallaxDrawableMaxOffset

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

```
fun setParallaxDrawableMaxOffset(offset: Int): Unit
```

Sets default parallax offset in pixels for bitmap moving vertically. This method must be called before[enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax()).  

|                                      Parameters                                       |
|---------------------------------------------------------------------------------------|------------------------------|
| `offset: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Offset in pixels (e.g. 120). |

|                                                                      See also                                                                      |
|----------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax()) |   |

### setSolidColor

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

```
fun setSolidColor(color: @ColorInt Int): Unit
```

Convenient method to set color in bottom drawable. If app is not using default[ColorDrawable](https://developer.android.com/reference/android/graphics/drawable/ColorDrawable.html), app should not use this method. It's safe to call setSolidColor() before calling[enableParallax](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#enableParallax()).  

|                                                                                   Parameters                                                                                    |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
| `color: @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | color for bottom drawable. |

### setupVideoPlayback

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

```
fun setupVideoPlayback(playbackGlue: PlaybackGlue): Unit
```

Enable video playback and set proper[PlaybackGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlueHost). This method by default creates a VideoSupportFragment and VideoSupportFragmentGlueHost to host the PlaybackGlue. This method must be called after calling details Fragment super.onCreate(). This method can be called multiple times to replace existing PlaybackGlue or calling setupVideoPlayback(null) to clear. Note a typical[PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue)subclass releases resources in[onDetachedFromHost](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue#onDetachedFromHost()), when the[PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue)subclass is not doing that, it's app's responsibility to release the resources.  

|                                                     Parameters                                                      |
|---------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| `playbackGlue: `[PlaybackGlue](https://developer.android.com/reference/kotlin/androidx/leanback/media/PlaybackGlue) | The new PlaybackGlue to set as background or null to clear existing one. |

|                                                                                    See also                                                                                    |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [onCreateVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateVideoSupportFragment()) |   |
| [onCreateGlueHost](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#onCreateGlueHost())                         |   |

### switchToRows

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

```
fun switchToRows(): Unit
```

Switch to rows fragment.  

### switchToVideo

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

```
fun switchToVideo(): Unit
```

Switch to video fragment, note that this method is not affected by result of[canNavigateToVideoSupportFragment](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragmentBackgroundController#canNavigateToVideoSupportFragment()). If the method is called in DetailsSupportFragment.onCreate() it will make video fragment to be initially focused once it is created.

Calling switchToVideo() in DetailsSupportFragment.onCreate() will clear the activity enter transition and shared element transition.

If switchToVideo() is called after[prepareEntranceTransition](https://developer.android.com/reference/kotlin/androidx/leanback/app/BaseSupportFragment#prepareEntranceTransition())and before[onEntranceTransitionEnd](https://developer.android.com/reference/kotlin/androidx/leanback/app/DetailsSupportFragment#onEntranceTransitionEnd()), it will be ignored.

If[prepareEntranceTransition](https://developer.android.com/reference/kotlin/androidx/leanback/app/BaseSupportFragment#prepareEntranceTransition())is called after switchToVideo(), an IllegalStateException will be thrown.