Ali*_*Ali 5 android-jetpack-compose
100.dp如何在特定的盒子/容器(即 Size )内放置文本
有没有办法在 Compose 中将字符串放入 Box 中?
这是我尝试过的:
@Composable
fun playText() {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color(0xFF242E38)),
contentAlignment = Alignment.Center
) {
Row(modifier = Modifier
.background(Color(0xFFEEEEEE))
.width(100.dp)
.height(100.dp)
) {
Text(
text = "FIT ME",
modifier = Modifier
.fillMaxSize()
.wrapContentSize(
Alignment.Center,
unbounded = true
)
.requiredSize(100.dp),
color = Color(0xFF242E38),
fontSize = 50.sp,
style = TextStyle.Default.copy(
background = Color(0xFFEAC43D)
)
)
}
}
}
@Preview(showBackground = true)
@Composable
fun show() {
playText()
}
Run Code Online (Sandbox Code Playgroud)
这是当前结果:
预期结果如下 ( which I achieved by decreasing the font size, just to demonstrate what is expected):
| 归档时间: |
|
| 查看次数: |
4016 次 |
| 最近记录: |