Jetpack compose 中第一项较大的网格
我正在尝试使用 jetpack compose 来实现此视图:
我创建了一行,其中包含权重为 0.7 的图像,以及一列,其中包含权重为 0.3 的较小图像。 但列的底部总是有填充,并且它们不会完美对齐。 我的代码:
@Composable
fun TrendingSection() {
Row(horizontalArrangement = Arrangement.SpaceBetween) {
Image(
painter = painterResource(id = R.drawable.shadmehr),
contentDescription = "First trending music",
modifier = Modifier
.weight(0.7f)
.padding(4.dp)
.clip(RoundedCornerShape(16.dp))
)
Column(
verticalArrangement = Arrangement.SpaceAround,
modifier = Modifier
.weight(0.3f)
) {
Image(
painter = painterResource(id = R.drawable.shadmehr),
contentDescription = "First trending music",
modifier = Modifier
.padding(4.dp)
.clip(RoundedCornerShape(16.dp))
)
Image(
painter = painterResource(id = R.drawable.shadmehr),
contentDescription = "First trending music",
modifier = Modifier
.padding(4.dp)
.clip(RoundedCornerShape(16.dp))
)
}
}
}
有人知道问题是什么或者知道更好的解决方案吗?
I'm trying to achieve this view with jetpack compose:
I create a row consisting of an image with a weight 0.7 and a column that contains those smaller images with a weight 0.3.
But there is always padding at bottom of the column and they won't align perfectly.
My code:
@Composable
fun TrendingSection() {
Row(horizontalArrangement = Arrangement.SpaceBetween) {
Image(
painter = painterResource(id = R.drawable.shadmehr),
contentDescription = "First trending music",
modifier = Modifier
.weight(0.7f)
.padding(4.dp)
.clip(RoundedCornerShape(16.dp))
)
Column(
verticalArrangement = Arrangement.SpaceAround,
modifier = Modifier
.weight(0.3f)
) {
Image(
painter = painterResource(id = R.drawable.shadmehr),
contentDescription = "First trending music",
modifier = Modifier
.padding(4.dp)
.clip(RoundedCornerShape(16.dp))
)
Image(
painter = painterResource(id = R.drawable.shadmehr),
contentDescription = "First trending music",
modifier = Modifier
.padding(4.dp)
.clip(RoundedCornerShape(16.dp))
)
}
}
}
Anyone knows what is the problem or know a better solution for doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论