如何解决Jetpack撰写-具有两个填充父级并从一开始就对齐的文本,例如表格视图
我希望在撰写时具有这样的表格视图。我以这种方式将Columns与row一起使用。但是问题是,即使我从一开始就没有通过文字的对齐和对齐,也无法使文本填充所有父项。
但是结果从一开始就是正确的。
Column {
pairs.forEach {
Row {
Text(it.first,Modifier.weight(1f).background(Color.Blue),textAlign = TextAlign.Start)
Text(it.second,Modifier.weight(1f),textAlign = TextAlign.Start)
}
}
我将背景色设置为蓝色,以查看文本是否真的填充了父级。但似乎它不会填满父项,而且这里的重量也无法恢复。
解决方法
对于撰写1.0.0-alpha04版本,它可以正常工作,但是对于1.0.0-alpha05版本,我们需要使用TextAlign.Start
代替TextAlign.Justify
以获得预期的结果。
根据文档
/**
* Stretch lines of text that end with a soft line break to fill the width of
* the container.
*
* Lines that end with hard line breaks are aligned towards the [Start] edge.
*/
Justify,/**
* Align the text on the leading edge of the container.
*
* For Left to Right text ([ResolvedTextDirection.Ltr]),this is the left edge.
*
* For Right to Left text ([ResolvedTextDirection.Rtl]),like Arabic,this is the right edge.
*/
Start,
但是我不确定TextAlign.Start
为什么能在aplha4和aplha5中工作
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。