簡體   English   中英

如何在 android Jetpack Compose 中刪除文本?

[英]How to strikethrough Text in android Jetpack Compose?

我想刪除 Android Jetpack Compose 中的Text 我已經檢查了一些文檔,但我仍然沒有找到符合我想要實現的目標。

https://developer.android.com/jetpack/compose/text

這是我的文本組件:

Text("$863",fontSize = 24.sp, modifier = Modifier.width(IntrinsicSize.Min), maxLines = 1)

這就是我想要實現的目標:

在此處輸入圖像描述

任何人都可以幫助我或給我任何想法嗎?

為文本添加樣式

@Composable
fun TextWithLineThroughExample(){
    Text(
        text = "Text with LineThrough",
        style = TextStyle(textDecoration = TextDecoration.LineThrough)
    )
}

在此處輸入圖片說明

我建議使用調整后的屬性復制當前樣式:

@Composable
fun textWithLineThroughExample(){
    Text(
        text = "Text with LineThrough",
        style = LocalTextStyle.current.copy(textDecoration = TextDecoration.LineThrough)
    )
}

此方法保留所有其他現有樣式屬性(例如在ProvideTextStyle塊中)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM