I have 3 views that i included in flow helper of constraint layout and are laid out like this:
|TextView1| |View(delimiter)| |TextView2|
when text of TextView2 doesn't fit, it moves to next line:
|TextView1| |View(delimiter)| |TextView2|
the problem here is that when TextView2 moves to next line i need to remove or make View(delimiter) visibility as gone, and to do so i need a way to know if flow layout has more than one row.
i tried to look for built-in functions inside flow helper but found nothing.
Currently there is no method to get the
Flow Layoutrow count but you can achieve this kind of effect by creating a subclass ofandroidx.constraintlayout.helper.widget.Flowand override the functionfun updatePostLayout(container: ConstraintLayout)which is used when you want to update its internal object post layout or set up connections for the pointed elements. In this method you can have your custom logics to change the visibility of the View(delimiter) accordingly. Below is an example of theCustomFlowsubclass:And can be used in your xml like below:
Result when TextView2 is short (View-delimiter is visible):
Result when TextView2 is long and goes to the next line (View-delimiter is gone):