title: Use FlexboxLayout programmatically
body: <p>I'm facing some problems trying to create a simple interface using <a href="https://github.com/google/flexbox-layout" rel="nofollow noreferrer">FlexboxLayout</a>.
  I create the view in .xml file and all works as expected, but when I try to create the same view programmatically, I'm not be able to set the <code>layout_flexBasisPercent</code>.
  I'm trying to achive something like this:
  <a href="https://i.stack.imgur.com/u9BF4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u9BF4.png" alt="enter image description here"></a></p>
  
  <p>Here it is the xml code:</p>
  
  <pre><code>&lt;com.google.android.flexbox.FlexboxLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:flexDirection="row"
      tools:context=".MainActivity"&gt;
  
      &lt;com.google.android.flexbox.FlexboxLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          app:flexDirection="row"
          app:layout_flexBasisPercent="30%"
          app:layout_order="2"&gt;
  
          &lt;TextView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:text="@string/lorem"/&gt;
  
      &lt;/com.google.android.flexbox.FlexboxLayout&gt;
  
      &lt;com.google.android.flexbox.FlexboxLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          app:flexDirection="row"
          app:layout_flexBasisPercent="70%"
          app:layout_order="1" &gt;
  
          &lt;ImageView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:scaleType="centerCrop"
              android:src="@drawable/random"/&gt;
  
      &lt;/com.google.android.flexbox.FlexboxLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>And I'm trying to reproduce the same view programmatically with this code, but doesn't work:</p>
  
  <pre><code>    FlexboxLayout fb = findViewById(R.id.fb_main);
      fb.setLayoutDirection(FlexDirection.ROW);
  
      // Create right subregion on main layout
      FlexboxLayout right = new FlexboxLayout(this);
      FlexboxLayout.LayoutParams lpRight =
              new FlexboxLayout.LayoutParams(
                      FlexboxLayout.LayoutParams.MATCH_PARENT,
                      FlexboxLayout.LayoutParams.MATCH_PARENT);
      lpRight.setFlexBasisPercent(30f);
      lpRight.setOrder(2);
      lpRight.setLayoutDirection(FlexDirection.ROW);
      // Right subregions contains a Textview
      TextView tv = new TextView(this);
      tv.setLayoutParams(lpRight);
      tv.setText(getResources().getString(R.string.lorem));
      right.addView(tv);
  
      // Create left subregion on main layout
      FlexboxLayout left = new FlexboxLayout(this);
      FlexboxLayout.LayoutParams lpLeft =
              new FlexboxLayout.LayoutParams(
                      FlexboxLayout.LayoutParams.MATCH_PARENT,
                      FlexboxLayout.LayoutParams.MATCH_PARENT);
      lpLeft.setFlexBasisPercent(70f);
      lpLeft.setOrder(1);
      lpLeft.setLayoutDirection(FlexDirection.ROW);
      // Left subregion contains an Imageview
      ImageView iv = new ImageView(this);
      iv.setLayoutParams(lpLeft);
      iv.setImageResource(R.drawable.random);
      iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
      left.addView(iv);
  
      fb.addView(left);
      fb.addView(right);
  </code></pre>
  
  <p>Can anyone find the error ? Or what I'm doing wrong?</p>
  
  <p>Thank you.</p>