androidandroid-flexboxlayout

Android Flexbox setFlexBasisPercent not working


I'm using android's now layout - FlexboxLayout. When I add some view to FlexboxLayout programmatically,
FlexboxLayout.setWidth( int ) is working but FlexboxLayout.setFlexBasisPercent( float ) not. Why!!! I can't understand. Here is my code.

enter image description here

------------- I Find Answer!!! 2017/07/30/11:59

my mistake is that

lp.setFlexBasisPercent(10)

FlexboxLayout.setFlexBasisPercent(0.1f) was right!!!


Solution

  • Documentation on Flexbox is scarce, but from what im gathering, the parent element has to have a defined width/height in order for that to work. Here is a quote.

    This attribute is only effective when the parent's length is definite (MeasureSpec mode is MeasureSpec.EXACTLY) https://github.com/google/flexbox-layout