title: Moving buttons at desired locations
body: <p>I have this problem: I want to put some Buttons at a certain locations, for example at the four squares of the screen (resolved) and I also want them to become red when clicking on each one, at exactly those locations (not resolved yet).</p>
  
  <p>This is the main xml:</p>
  
  <pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/scrollView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true"
      android:layout_weight="15"
      android:orientation="vertical"&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:components="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:id="@+id/layout1"&gt;
          &lt;Button
              android:id="@+id/one"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:background="@color/colorPrimary"/&gt;
          &lt;Button
              android:id="@+id/two"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_alignParentEnd="true"
              android:background="@color/colorPrimary" /&gt;
          &lt;Button
              android:id="@+id/three"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_alignParentBottom="true"
              android:background="@color/colorPrimary" /&gt;
          &lt;Button
              android:id="@+id/four"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_alignParentBottom="true"
              android:layout_alignParentEnd="true"
              android:background="@color/colorPrimary"/&gt;
      &lt;/RelativeLayout&gt;
  &lt;/ScrollView&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>And this is the main java:</p>
  
  <pre><code>RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout1);
      RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
             RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      Button btnTag = new Button(this);
      btnTag.setLayoutParams(rel_btn);
      btnTag.setBackgroundColor(Color.BLUE);
      btnTag.setOnClickListener(listen);
      layout.addView(btnTag);
  }
  
   private View.OnClickListener listen = new View.OnClickListener() {
      @Override
      public void onClick(View view) {
         if (pressed != null) {
            Button button1 = (Button) pressed;
            button1.setBackgroundColor(Color.BLUE);
         }
         Button button2 = (Button) view;
         GradientDrawable drawable = new GradientDrawable();
         drawable.setShape(GradientDrawable.RECTANGLE);
         drawable.setStroke(8, Color.RED);
         button2.setBackgroundDrawable(drawable);
         pressed = view;
      }
  </code></pre>