SubtitleView
@UnstableApi
class SubtitleView : FrameLayout
| kotlin.Any | ||||
| ↳ | android.view.View | |||
| ↳ | android.view.ViewGroup | |||
| ↳ | android.widget.FrameLayout | |||
| ↳ | androidx.media3.ui.SubtitleView |
A view for displaying subtitle Cues.
Summary
Nested types |
|---|
@DocumentedThe type of |
Constants |
|
|---|---|
const Float |
DEFAULT_BOTTOM_PADDING_FRACTION = 0.08fThe default bottom padding to apply when |
const Float |
DEFAULT_TEXT_SIZE_FRACTION = 0.0533fThe default fractional text size. |
const Int |
VIEW_TYPE_CANVAS = 1Indicates subtitles should be displayed using a |
const Int |
VIEW_TYPE_WEB = 2Indicates subtitles should be displayed using a |
Public constructors |
|---|
SubtitleView(context: Context!) |
SubtitleView(context: Context!, attrs: AttributeSet?) |
Public functions |
|
|---|---|
Unit |
setApplyEmbeddedFontSizes(applyEmbeddedFontSizes: Boolean)Sets whether font sizes embedded within the cues should be applied. |
Unit |
setApplyEmbeddedStyles(applyEmbeddedStyles: Boolean)Sets whether styling embedded within the cues should be applied. |
Unit |
setBottomPaddingFraction(bottomPaddingFraction: Float)Sets the bottom padding fraction to apply when |
Unit |
Sets the cues to be displayed by the view. |
Unit |
setFixedTextSize(unit: @Dimension Int, size: Float)Sets the text size to a given unit and value. |
Unit |
setFractionalTextSize(fractionOfHeight: Float)Sets the text size to be a fraction of the view's remaining height after its top and bottom padding have been subtracted. |
Unit |
setFractionalTextSize(fractionOfHeight: Float, ignorePadding: Boolean)Sets the text size to be a fraction of the height of this view. |
Unit |
setStyle(style: CaptionStyleCompat!)Sets the caption style. |
Unit |
Styles the captions using |
Unit |
Sets the text size based on |
Unit |
setViewType(@SubtitleView.ViewType viewType: Int)Sets the type of |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
DEFAULT_BOTTOM_PADDING_FRACTION
const val DEFAULT_BOTTOM_PADDING_FRACTION = 0.08f: Float
The default bottom padding to apply when line is DIMEN_UNSET, as a fraction of the viewport height.
| See also | |
|---|---|
setBottomPaddingFraction |
DEFAULT_TEXT_SIZE_FRACTION
const val DEFAULT_TEXT_SIZE_FRACTION = 0.0533f: Float
The default fractional text size.
| See also | |
|---|---|
setFractionalTextSize |
VIEW_TYPE_CANVAS
const val VIEW_TYPE_CANVAS = 1: Int
Indicates subtitles should be displayed using a Canvas. This is the default.
VIEW_TYPE_WEB
const val VIEW_TYPE_WEB = 2: Int
Indicates subtitles should be displayed using a WebView.
This will use CSS and HTML styling to render the subtitles. This supports some additional styling features beyond those supported by VIEW_TYPE_CANVAS such as vertical text.
Public constructors
Public functions
setApplyEmbeddedFontSizes
fun setApplyEmbeddedFontSizes(applyEmbeddedFontSizes: Boolean): Unit
Sets whether font sizes embedded within the cues should be applied. Enabled by default. Only takes effect if setApplyEmbeddedStyles is set to true.
| Parameters | |
|---|---|
applyEmbeddedFontSizes: Boolean |
Whether font sizes embedded within the cues should be applied. |
setApplyEmbeddedStyles
fun setApplyEmbeddedStyles(applyEmbeddedStyles: Boolean): Unit
Sets whether styling embedded within the cues should be applied. Enabled by default. Overrides any setting made with setApplyEmbeddedFontSizes.
| Parameters | |
|---|---|
applyEmbeddedStyles: Boolean |
Whether styling embedded within the cues should be applied. |
setBottomPaddingFraction
fun setBottomPaddingFraction(bottomPaddingFraction: Float): Unit
Sets the bottom padding fraction to apply when line is DIMEN_UNSET, as a fraction of the view's remaining height after its top and bottom padding have been subtracted.
Note that this padding is applied in addition to any standard view padding.
| Parameters | |
|---|---|
bottomPaddingFraction: Float |
The bottom padding fraction. |
setFixedTextSize
fun setFixedTextSize(unit: @Dimension Int, size: Float): Unit
Sets the text size to a given unit and value.
See TypedValue for the possible dimension units.
setFractionalTextSize
fun setFractionalTextSize(fractionOfHeight: Float): Unit
Sets the text size to be a fraction of the view's remaining height after its top and bottom padding have been subtracted.
Equivalent to #setFractionalTextSize(fractionOfHeight, false).
| Parameters | |
|---|---|
fractionOfHeight: Float |
A fraction between 0 and 1. |
setFractionalTextSize
fun setFractionalTextSize(fractionOfHeight: Float, ignorePadding: Boolean): Unit
Sets the text size to be a fraction of the height of this view.
| Parameters | |
|---|---|
fractionOfHeight: Float |
A fraction between 0 and 1. |
ignorePadding: Boolean |
Set to true if |
setStyle
fun setStyle(style: CaptionStyleCompat!): Unit
Sets the caption style.
| Parameters | |
|---|---|
style: CaptionStyleCompat! |
A style for the view. |
setUserDefaultStyle
fun setUserDefaultStyle(): Unit
Styles the captions using getUserStyle if CaptioningManager is available and enabled.
Otherwise (and always before API level 19) uses a default style.
setUserDefaultTextSize
fun setUserDefaultTextSize(): Unit
Sets the text size based on getFontScale if CaptioningManager is available and enabled.
Otherwise (and always before API level 19) uses a default font scale of 1.0.
setViewType
fun setViewType(@SubtitleView.ViewType viewType: Int): Unit
Sets the type of View used to display subtitles.
NOTE: VIEW_TYPE_WEB is currently very experimental, and doesn't support most styling and layout properties of Cue.
| Parameters | |
|---|---|
@SubtitleView.ViewType viewType: Int |
The |