google / flexbox-layout

Flexbox for Android
Apache License 2.0
18.24k stars 1.79k forks source link

Is there possible to calculate the size of child view on each row/column? #543

Closed wilspheal closed 4 years ago

wilspheal commented 4 years ago

Issues and steps to reproduce

I want to calculate the size of the child's view before its wrapped. I've tried to use isWrapBefore() attribute on the view like ((FlexboxLayout.LayoutParams) flexView.getLayoutParams()).isWrapBefore() so I thought I could get the last index of the child before it wrapped while using loops but it returns false. I notice that the layout_wrapbefore attribute doesn't work if it wrapped automatically.

Expected behavior

I hope I can explain my issue better, but here is what I want to achieve. I just want to get the size of the children on each row before its wrapped. Ex: [original list] a, b, c, d, e, f, g [0] | a b c d | [1] | e f g . | 1st row will return 4 and the 2nd one will return 3. Any way to do that?

Version of the flexbox library

2.0.1

thagikura commented 4 years ago

After all views are laid out, it's possible but it's not possible to calculate that beforehand because it depends on the size of the device.