我想垂直放置我自己的组件(比如一个文本组件),这样我就可以指定相对于文本组件底部的y偏移量。我如何在Jetpack合成中做到这一点?
比如说
Column {
Text("Something", modifier = Modifier.offset(y=10.dp))
}
但是10dp不是代表文本组件的顶部y位置,而是底部y位置。基本上考虑了文本的高度,即使文本大小改变。所以y = offset.y - height
在我看来有两个问题
1.字体大小是可以改变的,所以我不能硬编码的文字高度。
1.我需要知道我的文本组件在合成过程中的大小,但我不知道如何得到它。
1条答案
按热度按时间ajsxfq5m1#
你可以选择定制的可组合产品
您也可以使用自定义修饰符。使用
layout
修饰符 checkout