gpt4 book ai didi

android - 在 FlexboxLayout 中换行

转载 作者:行者123 更新时间:2023-12-05 01:00:59 27 4
gpt4 key购买 nike

我正在使用 FlexboxLayout 添加一些 EditTexts。每个 EditText 仅包含 1 个单词字符。我也使用 editText 作为空间,但保持它不可见。我使用布局设置 FlexWrap 作为“换行”。例如,如果我有两个单词,第二个单词的一些字母会转到下一行。但是,我希望下一个单词(一组editText)转到下一行,而不仅仅是最后几个字母(editText)。

有没有办法对这些编辑文本进行分组并使整个单词转到下一行。或者有什么方法可以在程序本身内换行。我尝试将“EditText”添加到线性布局并将其添加到“FlexboxLayout”,但它不起作用。

最佳答案

使用此属性在 FlexboxLayout 中开始新的一行。

app:layout_wrapBefore="true"

在您的情况下,只需将此属性应用于您要开始新行的 EditText

引用自FlexboxLayout docs :

layout_wrapBefore (boolean)

This attribute forces a flex line wrapping, the default value is false. i.e. if this is set to true for a flex item, the item will become the first item of a flex line. (A wrapping happens regardless of the flex items being processed in the previous flex line) This attribute is ignored if the flex_wrap attribute is set to nowrap. The equivalent attribute isn't defined in the original CSS Flexible Box Module specification, but having this attribute is useful for Android developers. For example, to flatten the layouts when building a grid-like layout or for a situation where developers want to put a new flex line to make a semantic difference from the previous one, etc.

关于android - 在 FlexboxLayout 中换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47594233/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com