title: FlowLayout in android
body: <p>I needed a view as in figure below. I avoided the use of GridView because i was unable to scroll to lower parts of my app as the GridView takes almost all the screen. And scrolling would only scroll gridview and not the app in overall. Hence I created the the following layout using LinearLayout which contains ImageView and TextView for the items. The four LinearLayout itself is contained in a LinearLayout.</p>
  
  <p><a href="https://i.stack.imgur.com/38RKx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/38RKx.jpg" alt="enter image description here"></a></p>
  
  <p>Now the problem is how do i make a layout which automatically adjusts to a little bigger size like in figure below.</p>
  
  <p><a href="https://i.stack.imgur.com/ObEqy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ObEqy.jpg" alt="enter image description here"></a></p>
  
  <p>I used various flowlayout libraries like <a href="https://github.com/ApmeM/android-flowlayout" rel="nofollow noreferrer">library1</a> and <a href="https://github.com/blazsolar/FlowLayout" rel="nofollow noreferrer">library2</a> but both of them didnot work for me because i wasn't able to scroll and my linearlayout was squished too.</p>
  
  <p>Below is my code for the linear layout.</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin"
  tools:context="com.test.FirstHomeActivity"&gt;
  
  
  
  
      &lt;LinearLayout
          android:id="@+id/llFeatured1"
          android:clickable="true"
          android:onClick="featuredClick1"
          android:background="@drawable/card_layout"
          android:layout_width="wrap_content" android:orientation="vertical"
          android:layout_height="290dp"
          android:minHeight="290dp"&gt;
          &lt;ImageView
              android:id="@+id/featuredImg1"
              android:layout_margin="2dp"
              android:layout_width="166dp"
              android:layout_height="264dp"
              /&gt;
  
          &lt;TextView
              android:id="@+id/item2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Medium Text"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:layout_marginLeft="10dp"
              android:layout_marginTop="5dp"
              android:padding="2dp"
              android:textColor="#33CC33" /&gt;
          &lt;TextView
              android:id="@+id/textView2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TextView"
              android:layout_marginLeft="10dp"/&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/llFeatured2"
          android:clickable="true"
          android:onClick="featuredClick2"
          android:background="@drawable/card_layout"
          android:layout_margin="5dp"
          android:layout_width="wrap_content" android:orientation="vertical"
          android:layout_height="290dp"
          android:minHeight="290dp"&gt;
          &lt;ImageView
              android:id="@+id/featuredImg2"
              android:layout_margin="2dp"
              android:layout_width="166dp"
              android:layout_height="264dp"
              /&gt;
  
          &lt;TextView
              android:id="@+id/item"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Medium Text"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:layout_marginLeft="10dp"
              android:layout_marginTop="5dp"
              android:padding="2dp"
              android:textColor="#33CC33" /&gt;
          &lt;TextView
              android:id="@+id/textView"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TextView"
              android:layout_marginLeft="10dp"/&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/llFeatured3"
          android:clickable="true"
          android:onClick="featuredClick3"
          android:background="@drawable/card_layout"
          android:layout_margin="5dp"
          android:layout_width="wrap_content" android:orientation="vertical"
          android:layout_height="290dp"
          android:minHeight="290dp"&gt;
          &lt;ImageView
              android:id="@+id/featuredImg3"
              android:layout_margin="2dp"
              android:layout_width="166dp"
              android:layout_height="264dp"
              /&gt;
  
          &lt;TextView
              android:id="@+id/item3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Medium Text"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:layout_marginLeft="10dp"
              android:layout_marginTop="5dp"
              android:padding="2dp"
              android:textColor="#33CC33" /&gt;
          &lt;TextView
              android:id="@+id/textView3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TextView"
              android:layout_marginLeft="10dp"/&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any kind of example source code or any solution would be much appreciated. Thanks in advance.</p>