Jetpack Compose-立柱-重心 [英] Jetpack Compose - Column - Gravity center

查看:118
本文介绍了Jetpack Compose-立柱-重心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jetpack Compose创建布局,并且有一列.我想要此列内的中心项目:

I'm creating a layout with Jetpack Compose and there is a column. I would like center items inside this column:

 Column(modifier = ExpandedWidth) {
        Text(text = item.title)
        Text(text = item.description)
 }

推荐答案

您可以按照以下步骤在各个项目上应用重力,然后它将使项目居中.

You have the option to apply gravity on the individual items as follows then it will center the items.

Column(modifier = ExpandedWidth) {
       Text(modifier = Gravity.Center, text = item.title)
       Text(modifier = Gravity.Center, text = item.description)
}

这篇关于Jetpack Compose-立柱-重心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆