简体   繁体   English

Jetpack 撰写“文本”function 已弃用 (1.0.0-alpha09)

[英]Jetpack compose “Text” function deprecated (1.0.0-alpha09)

(config: compose_version = '1.0.0-alpha09' kotlin_version = "1.4.21") (配置:compose_version = '1.0.0-alpha09' kotlin_version = "1.4.21")

The Jetpack Composable function "Text" is deprecated Jetpack 可组合 function“文本”已弃用

Text( // <===== Strikethrough in Android Studio
    text = "Anna"
)

but I can't figure out how to replace it.但我不知道如何更换它。 The doc says to replace by... Text文档说要替换为... 文本

@Deprecated(
    message = "Use androidx.compose.material.Text for a high level Text component that " +
        "consumes theming information, or androidx.compose.foundation.text.BasicText for a basic " +
        "unopinionated component that does not have default theming",
    replaceWith = ReplaceWith(
        "Text(text, modifier, color, fontSize, fontStyle, fontWeight, fontFamily, " +
            "letterSpacing, textDecoration, textAlign, lineHeight, overflow, softWrap, maxLines, " +
            "onTextLayout, style)",
        "androidx.compose.material.Text"
    )
)

Change your androidx.compose.foundation.Text import to将您的androidx.compose.foundation.Text导入更改为

import androidx.compose.material.Text

to use the non-deprecated Material version of Text , which is the drop in replacement for what Text did in previous alphas.使用Text的非弃用 Material 版本,这是替代Text在以前的 alpha 中所做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用新的 compose 1.0.0-alpha09 - how can I use the new compose 1.0.0-alpha09 更新到WorkManager 1.0.0-alpha09后编译错误 - Compile errors after updating to WorkManager 1.0.0-alpha09 为什么从导航组件版本1.0.0-alpha09中删除addDefaultArguments()? 什么是WorkAround从活动传递arg到StartDestination? - Why addDefaultArguments() removed from Navigation Component version 1.0.0-alpha09? What is WorkAround to pass arg to StartDestination from Activity? Jetpack compose - 使用 1.0.0-alpha02 嵌套导航 - Jetpack compose - nested navigation with 1.0.0-alpha02 OutlineTextField 、TextField 在 Jetpack Compose 1.0.0-alpha02 中不起作用 - OutlineTextField , TextField not working in Jetpack Compose 1.0.0-alpha02 升级到带有 Kotlin 1.4.30 错误的 Jetpack Compose 1.0.0-alpha12 - Upgrading to Jetpack Compose 1.0.0-alpha12 with Kotlin 1.4.30 error 使用 Jetpack Compose 1.0.0-alpha11 时如何手动导入扩展函数? - How to manually import extension functions when using Jetpack Compose 1.0.0-alpha11? Jetpack Compose Crossfade 在 Alpha 中损坏 - Jetpack Compose Crossfade broken in Alpha 弯曲的文本 Jetpack 撰写 - Curved text Jetpack compose Jetpack Compose 中的可扩展文本 - Expandable Text in Jetpack Compose
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM