android - Jetpack 撰写“文本”功能已弃用 (1.0.0-alpha09)
问题描述
(配置:compose_version = '1.0.0-alpha09' kotlin_version = "1.4.21")
Jetpack 可组合功能“文本”已弃用
Text( // <===== Strikethrough in Android Studio
text = "Anna"
)
但我不知道如何更换它。文档说要替换为 ... 文本
@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"
)
)
解决方案
androidx.compose.foundation.Text
将您的导入更改为
import androidx.compose.material.Text
使用未弃用的 Material 版本Text
,这是替代Text
之前 alpha 版本的替代品。
推荐阅读
- c++ - 使用`std::find`时,为什么错误与'operator=='不匹配?
- amazon-web-services - 让 AWS 在启动时自动将 EC2 卷附加到 Ubuntu 实例
- docker - 部署到 Kubernetes 时如何包含 Azure Function Secret?
- c++ - 如何在 vscode 中构建、运行和删除可执行文件和虚拟文件
- arrays - Kotlin 序列到数组
- ios - 缩进 UITextField 文本和占位符
- jmeter - Jmeter:不从命令行给出的属性位置读取属性
- sql - 如何区分 SQL 中多列的值
- java - 在 Spring 和 Javax RS REST API 中继承的情况下,序列化 JSON 的差异
- firebase - firebase 动态链接是否适用于 PWA 应用程序?