# CueUtil

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/text/CueUtil.java+class:androidx.media3.common.text.CueUtil)

*** ** * ** ***


```
@UnstableApi
class CueUtil
```

<br />

*** ** * ** ***

Utility methods and constants for `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue` layout and styling.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/text/CueUtil#DEFAULT_BOTTOM_PADDING_FRACTION() = 0.08f` The default bottom padding to apply when `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#line()` is `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#DIMEN_UNSET()`, as a fraction of the viewport height. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/text/CueUtil#DEFAULT_TEXT_SIZE_FRACTION() = 0.0533f` The default fractional text size, as a fraction of the viewport height. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/text/CueUtil#resolveAnchorOffset(float,int,int,int)( fractionalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, @https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue.AnchorType anchorType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, cueDimension: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, viewDimension: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Calculates the pixel offset for placing a cue along a given axis (X or Y) relative to the viewport. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/text/CueUtil#resolveTextSize(int,float,int,int)( @https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue.TextSizeType textSizeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, textSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, rawViewHeight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, viewHeightMinusPadding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns the text size in px, derived from `textSize` and `textSizeType`. |

## Constants

### DEFAULT_BOTTOM_PADDING_FRACTION

```
const val DEFAULT_BOTTOM_PADDING_FRACTION = 0.08f: Float
```

The default bottom padding to apply when `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#line()` is `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#DIMEN_UNSET()`, as a fraction of the viewport height.

### DEFAULT_TEXT_SIZE_FRACTION

```
const val DEFAULT_TEXT_SIZE_FRACTION = 0.0533f: Float
```

The default fractional text size, as a fraction of the viewport height.

## Public functions

### resolveAnchorOffset

```
java-static fun resolveAnchorOffset(
    fractionalPosition: Float,
    @Cue.AnchorType anchorType: Int,
    cueDimension: Int,
    viewDimension: Int
): Float
```

Calculates the pixel offset for placing a cue along a given axis (X or Y) relative to the viewport.

If `fractionalPosition` is `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#DIMEN_UNSET()`, the cue is centered within the viewport. Otherwise, the offset is determined by aligning the specified `anchorType` of the cue with the `fractionalPosition` of the viewport.

| Parameters |
|---|---|
| `fractionalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The position of the cue's anchor, expressed as a fraction (between 0 and 1) of `viewDimension`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#DIMEN_UNSET()`. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue.AnchorType anchorType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The anchor type (e.g., `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#ANCHOR_TYPE_START()`, `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#ANCHOR_TYPE_MIDDLE()`, `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#ANCHOR_TYPE_END()`). |
| `cueDimension: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The pixel dimension (width or height) of the cue. |
| `viewDimension: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The pixel dimension (width or height) of the viewport. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The pixel offset of the start (top or left) of the cue, relative to the start (top or left) of the viewport. |

### resolveTextSize

```
java-static fun resolveTextSize(
    @Cue.TextSizeType textSizeType: Int,
    textSize: Float,
    rawViewHeight: Int,
    viewHeightMinusPadding: Int
): Float
```

Returns the text size in px, derived from `textSize` and `textSizeType`.

Returns `https://developer.android.com/reference/kotlin/androidx/media3/common/text/Cue#DIMEN_UNSET()` if `textSize == Cue.DIMEN_UNSET` or `
textSizeType == Cue.TYPE_UNSET`.