android - Jetpack Compose 水平对齐问题
问题描述
我需要将图像和文本视图定位到卡片的开头,子列水平居中对齐,但是正如您从照片中看到的那样,列以某种方式被拉伸了放置图像的屏幕宽度和中心的文本视图。任何人都可以看到我的代码有任何问题吗?
@Composable
fun TrainerCard(profile: TrainerProfile) {
Card(modifier = Modifier
.height(180.dp)
.fillMaxWidth()
.padding(4.dp)) {
Column(modifier = Modifier
.fillMaxHeight()
.width(120.dp)
.border(1.dp, color = Color.Red),
horizontalAlignment = Alignment.CenterHorizontally) {
Image(
modifier = Modifier
.size(120.dp)
.padding(top = 4.dp, start = 4.dp),
painter = painterResource(R.drawable.pokepals_logo),
contentDescription = null
)
Text(
text = profile.trainerName,
style = MaterialTheme.typography.subtitle1)
}
}
}
解决方案
推荐阅读
- jquery - 使用 jQuery 将图像适合表格单元格
- c++ - 我们可以在标准容器中使用 std::auto_ptr<> 吗?是的,但使用移动语义
- excel - 字符串值操作
- c# - 覆盖“公共”继承成员时无法更改访问修饰符
- javascript - 绑定滚动事件不会在角度指令中触发
- reactjs - 如何将参数传递给reactjs中的事件句柄
- ansible - 使用 Ansible 获取 VMware 虚拟机的 UUID
- neo4j - 有没有办法一起执行所有 3 个查询?
- c# - 如何通过 Socket C# 发送长字符串
- java - 如何使用 phantomjs 将多个 Web 元素传递到页面