Text

interface Text<T : Modifier> : Widget<T>

表示一个 Jetpack Compose Text 组件的接口定义。

此接口提供了一种声明式、构建器风格(builder-style)的 API,用于配置文本显示的核心属性。 它封装了 Compose Text 组件的常用功能,如设置文本内容、溢出行为、换行、最大行数和样式。

Author

M8Test, [email protected], https://m8test.com

Parameters

T

Modifier 的具体类型,用于实现链式调用和扩展。

See also

androidx.compose.material3.Text

官方 Material3 Text Composable 文档

Functions

Link copied to clipboard
abstract fun DisposableEffect(disposableEffectBuilder: DisposableEffect.() -> Unit)
Link copied to clipboard
Link copied to clipboard
abstract fun <V> getCompositionLocalValue(compositionLocal: ProvidableCompositionLocal<V>): V?

获取 compositionLocal 的值

Link copied to clipboard
abstract fun getContext(): ScriptContext

获取脚本上下文对象 ScriptContext.

Link copied to clipboard
abstract fun LaunchedEffect(launchedEffectBuilder: LaunchedEffect.() -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun setMaxLines(maxLines: Int)

设置文本可以跨越的最大行数。

Link copied to clipboard
abstract fun setModifier(modifierBuilder: T.() -> Unit)
Link copied to clipboard
abstract fun setOverflow(overflow: (TextOverflows) -> TextOverflow)

设置当文本超出其可用空间时的视觉溢出处理方式。

Link copied to clipboard
abstract fun setSoftWrap(softWrap: Boolean)

设置文本是否应在软换行符处自动换行。

Link copied to clipboard
abstract fun setStyle(style: TextStyle.() -> Unit)

配置文本的样式,如颜色、字体大小、字重等。

Link copied to clipboard
abstract fun setText(text: String)

设置要显示的文本内容。

Link copied to clipboard
abstract fun setVisible(visible: Boolean)

设置显示/隐藏当前 Composable

Link copied to clipboard
abstract fun SideEffect(sideEffectBuilder: SideEffect.() -> Unit)
Link copied to clipboard

设置所有需要用到的聚合状态,例如 DrawerState, BottomSheetState 等

Link copied to clipboard
abstract fun trackSingleState(state: SingleState)

添加当前 Composable 需要监听的状态,如果状态改变的话 Composable 会重组