kotlin 在jetpack合成中的图标上方添加文本

lb3vh1jj  于 2022-12-04  发布在  Kotlin
关注(0)|答案(2)|浏览(126)

有没有什么方法可以让我在Jetpack Compose中的特定图标上面显示一点描述,就像这张图片一样?

8xiog9wr

8xiog9wr1#

您可以使用方块。方块版面配置的子系会彼此堆栈。

Box{ 
    Text(text = "Text Above Icon", modifier = text alignment)
    Icon(... , modifier = icon alignment) 
    
}
q5iwbnjs

q5iwbnjs2#

/**  Text can be added above an icon in Jetpack Compose by using a combination of the Row and Column composables. The Row composable lays out its children in a single row while the Column composable lays out its children in a single column. To add text above the icon, the Row composable should be used first, followed by the Column composable. This will allow the text to be placed on the top of the icon. For example, the following code will add text above an icon: ***/
    
    Row { 
        Text(text = "Text Above Icon") 
        Column { 
            Icon(... ) 
        } 
    }

相关问题