google / flexbox-layout

Flexbox for Android
Apache License 2.0
18.26k stars 1.8k forks source link

getflexlines delay #488

Open charmeleon2 opened 5 years ago

charmeleon2 commented 5 years ago

Issues and steps to reproduce

when i add view, i want to get lines,but result seems to delayed. so i add another clickevent to check the result ,it's right.

Expected behavior

after add a view, getflexlines method return the right lines

Version of the flexbox library

1.0.0

public void add() { int flexItemCount = flexboxLayout.getFlexItemCount(); TextView textView = new TextView(this); textView.setText(Integer.toString(flexItemCount)); textView.setPadding(SizeUtils.dp2px(30f), SizeUtils.dp2px(5f), SizeUtils.dp2px(30f), SizeUtils.dp2px(5f)); textView.setBackgroundColor(Color.parseColor("#708090")); flexboxLayout.addView(textView); int count = flexboxLayout.getFlexItemCount(); Log.d("FLEX1",count+""); List flexLines = flexboxLayout.getFlexLines(); Log.d("FLEX1",flexLines.size()+""); }

public void change(View view) { List flexLines = flexboxLayout.getFlexLines(); Log.d("FLEX2",flexLines.size()+""); }

charmeleon2 commented 5 years ago

For example,when i add the third line's first item, getflexline return 2,but getflexitemcount return the right result. On change method, getflexlines return 3. 18