title: Make RelativeLayout scrollable
body: <p>I want to make a scrollable RelativeLayout where I can create Buttons with a x and y positions and custom width and height.
  Here is the code i got so far XML:</p>
  
  <pre><code>&lt;ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_below="@+id/buttonDel"
      android:fillViewport="true"&gt;
      &lt;LinearLayout android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:id="@+id/RL"&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>RelativeLayout linearLayout;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main3);
  
      linearLayout = (RelativeLayout) findViewById(R.id.RL);
      addButton();
  }
  
  private void addButton() {
  
      for(int i = 0; i &lt; 20; i++)
          for(int j = 0; j &lt; 4; j++)
          {
              Button but = new Button(this);
              but.setX(j * 200);
              but.setY(i * 200);
              but.setText("B" + i);
              linearLayout.addView(but, 200, 200);
          }
      }
  </code></pre>
  
  <p>It result in something that i want except the scrolling part. I don't know why the ScrollView isn't working.</p>
  
  <p><a href="https://i.stack.imgur.com/z00x9.jpg" rel="nofollow noreferrer">Screen so far.</a></p>
  
  <p><a href="https://i.stack.imgur.com/Xi4AD.jpg" rel="nofollow noreferrer">After I changed ScrollView layout_height="match_parent" to "warp_content"</a></p>