Mar*_*aie 4 android android-jetpack-compose
我想制作一个圆形文本,它将填充屏幕上的所有可用内容,但仍然保持圆形。这是我为该组件编写的代码。
Box(modifier = modifier
.padding(4.dp)
.fillMaxSize()
.clip(CircleShape),
contentAlignment = Alignment.Center
) {
Text(text = "hello", modifier = Modifier.fillMaxSize().background(Color.Yellow))
}
Run Code Online (Sandbox Code Playgroud)
而这并不是我想要的结果。关于如何实现这一目标有什么想法吗?
Gab*_*tti 12
您可以应用修饰符aspectRatio(1f)以在.heightwidthBox
就像是:
Box(modifier = Modifier
.padding(4.dp)
.fillMaxSize()
.aspectRatio(1f)
.background(Color.Blue, shape = CircleShape),
contentAlignment = Alignment.Center
) {
Text(text = "hello", color= Yellow, textAlign = TextAlign.Center)
}
Run Code Online (Sandbox Code Playgroud)
如果您想更好地控制文本可组合项,您也可以检查此问题。
| 归档时间: |
|
| 查看次数: |
5752 次 |
| 最近记录: |