Breaking to new line in FlexboxLayout

2.1k Views Asked by At

I am using a FlexboxLayout to add few EditTexts. Each EditText contains just 1 character of words.I am using editText for space as well but keeping it invisible.I am using layout setting FlexWrap as "wrap". For instance, if I have two words, some letters of the second word goes to the next line. However, I want the next word( a group of editText) to go to next line instead of just the last few letters(editText).

Is there someway to group these edittext and make the whole word go to next line.Or is there some way to break line within the programme itself. I tried adding 'EditText' to linear layout and adding it to 'FlexboxLayout', it did not work.

1

There are 1 best solutions below

0
On

Use this property to start a new line in FlexboxLayout.

app:layout_wrapBefore="true"

In your case, just apply this property to the EditText which you want start a new line.

Quote from 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.