Problem have this UI problem:
1) I have 3 textViews
which I want to hold in one parent view.
2) I want to populate as many items as possible in as few lines as possible.
3) Only between 2 items there is a separator.
Suggested algorithm:
Get the container's widthGet each item unspecified width (For that I have to create a custom textView to override onMeasure()
).
Calculate and keep aside "last line remaining width"
.
If next textView can fit in the last line remaining width:
else:
remaining width = (container's width - current
item's width)
I have two options:
I would fill a List of Lists and will populate the horizontal linear layouts via code.
Or fill the constraint layout via code (less generic and I guess more difficult).
Is there any simpler solution?
If I'm understanding your requirements correctly, I believe the FlexboxLayout library from Google should do exactly what you want.
You'd probably use a FlexboxLayout
(rather than a RecyclerView
with a FlexboxLayoutManager
), but it is good to note that this library also supports recycling.