我正在使用Jetpack Compose创建一个简单的闪存卡.
Unfortunately... I could not even find the official documentation, so my learning style has been trusting the autocorrect system...
无论如何,我相信问题要么是Box()的问题,要么是text()的问题. 我已经为长方体的重力添加了Align.CenterEnd.然而,就盒子而言,这似乎是唯一的居中方式.另一方面,text()没有给出任何方法来实现这一点(它很有吸引力,但似乎没有改变任何东西)
A hand in the right direction would be amazing.
顺便说一句,我知道这将是免费的回答.但是我该如何更改on click中$question的文本呢.正如我所认为的那样,复合物能让人耳目一新?...因此,应该在屏幕上重新生成吗?也许不是?
谢谢!
val typography = MaterialTheme.typography
val context = ContextAmbient.current
var question = "How many Bananas should go in my Smoothie?"
Column(modifier = Modifier.padding(30.dp).then(Modifier.fillMaxWidth())
.then(Modifier.wrapContentSize(Alignment.Center))
.clickable(onClick = { Toast.makeText(context, "3 Bananas are needed!", Toast.LENGTH_LONG).show()} ) /*question = "3 Bananas required"*/
.clip(shape = RoundedCornerShape(16.dp))) {
Box(modifier = Modifier.preferredSize(350.dp)
.gravity(align = Alignment.CenterHorizontally)
.border(width = 4.dp, color = Gray, shape = RoundedCornerShape(16.dp)),
shape = RoundedCornerShape(2.dp),
backgroundColor = DarkGray,
gravity = Alignment.CenterEnd) {
Text("$question",
style = typography.h4,
)
}
}