Hossein Nakhaeipoor
Hossein Nakhaeipoor

Reputation: 144

Count number of rows in flexbox

In my android application i have used flexbox-layout.
I am adding buttons dynamically into the flexbox.
I need to know how many rows are currently rendered (How many rows flexbox created to show the buttons)
This is my flexbox-layout:

<com.google.android.flexbox.FlexboxLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/filterActivity_tags_container"
    app:flexWrap="wrap"
    app:justifyContent="flex_end" />

Upvotes: 3

Views: 2567

Answers (2)

Sushant Gosavi
Sushant Gosavi

Reputation: 3835

Unfortunately Answer No You need to create your custom FlexboxLayout to get row count

There is some API such as

mFlexbox.getFlexLines().size()

mFlexbox.getFlexLinesInternal().size()

But this is give you wrong result because this play with data not view suppose you call removeAllView() still it give you same result because it does not update list after remove data, One another thing I have notice that it update line count after one child view already added to flexbox row .

This is my observation while implementing this this may be wrong on some case

Upvotes: 0

Hossein Nakhaeipoor
Hossein Nakhaeipoor

Reputation: 144

i have find the solution guys!

mFlexbox.getFlexLines().size()

Upvotes: 3

Related Questions