title: How to use Scroll View In Android
body: <p>I have use two scroll views for two different layout. And those two layouts are inside a Linear Layout. </p>
  
  <p>Here is my XML file. I don't why <code>ScrollView</code> is not working for me</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:orientation="horizontal" &gt;
  
      &lt;LinearLayout
              android:id="@+id/flightResultData"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="8dp"
              android:orientation="vertical" &gt;
  
              &lt;LinearLayout
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal" &gt;
  
                  &lt;LinearLayout
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:orientation="horizontal" &gt;
  
                      &lt;LinearLayout
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:orientation="vertical" &gt;
  
                          &lt;ImageView
                              android:id="@+id/onewayflightLogo"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="3dp"
                              android:src="@drawable/spicejet" /&gt;
  
                          &lt;TextView
                              android:id="@+id/onewayflightName"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="SpiceJet" /&gt;
  
                          &lt;TextView
                              android:id="@+id/onewayflightNumber"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="9W - 496" /&gt;
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
                          android:layout_marginTop="8dp"
                          android:layout_width="fill_parent"
                          android:layout_height="match_parent"
                          android:orientation="vertical" &gt;
  
                          &lt;TextView
                              android:id="@+id/onewayflightTime"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="5dp"
                              android:minLines="1"
                              android:text="06:00 - 7:05"
                              android:textSize="12dp" /&gt;
  
                          &lt;TextView
                              android:id="@+id/onewayflightDuration"
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="5dp"
                              android:minLines="1"
                              android:text="1h 35m | Non Stop"
                              android:textSize="10dp" /&gt;
                          &lt;TextView
                              android:id="@+id/onewayflightAmount"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="5dp"
                              android:minLines="1"
                              android:text="Rs 200000"
                              android:textSize="12dp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/LinearLayout&gt;
                  &lt;View
                      android:layout_width="1dp"
                      android:layout_height="60dp"
                      android:background="@android:color/darker_gray" /&gt;
                 &lt;LinearLayout
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:orientation="horizontal" &gt;
  
                      &lt;LinearLayout
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:orientation="vertical" &gt;
  
                          &lt;ImageView
                              android:id="@+id/retrunflightLogo"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="3dp"
                              android:src="@drawable/spicejet" /&gt;
  
                          &lt;TextView
                              android:id="@+id/retrunflightName"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="SpiceJet" /&gt;
  
                          &lt;TextView
                              android:id="@+id/retrunflightNumber"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="9W - 496" /&gt;
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
                          android:layout_marginTop="8dp"
                          android:layout_width="fill_parent"
                          android:layout_height="match_parent"
                          android:orientation="vertical" &gt;
  
                          &lt;TextView
                              android:id="@+id/retrunflightTime"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="5dp"
                              android:minLines="1"
                              android:text="06:00 - 7:05"
                              android:textSize="12dp" /&gt;
  
                          &lt;TextView
                              android:id="@+id/retrunflightDuration"
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="5dp"
                              android:minLines="1"
                              android:text="1h 35m |Non Stop"
                              android:textSize="10dp" /&gt;
  
                          &lt;TextView
                              android:id="@+id/retrunflightAmount"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_marginLeft="5dp"
                              android:minLines="1"
                              android:text="Rs 200000"
                              android:textSize="12dp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is my main layout in which I am inflating my above xml dynamically through a loop </p>
  
  <pre><code>&lt;LinearLayout
          android:id="@+id/flightResultData"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/sortFlightLayouts"
          android:layout_marginLeft="8dp"
          android:orientation="vertical" &gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And in my activity code I am doing this:</p>
  
  <pre><code>void setTestResultData(){
  
      flightResult=(LinearLayout)findViewById(R.id.flightResultData);
      LinearLayout.LayoutParams flightDetailsLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      LinearLayout.LayoutParams forUnderLine = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
      forUnderLine.setMargins(0,0, 0, 0);
      for(int i=0;i &lt; 13;i++){
          LinearLayout flightInformations=(LinearLayout)inflater.inflate(R.layout.flight_details_layout, null);
          flightResult.addView(flightInformations);
      }
  }
  </code></pre>