title: Set border to LinearLayout programmatically
body: <p>I need to set a border to a LinearLayout when the user click on it. Every solution I have tried so far change the color of all the LinearLayout, not just the border.</p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/linearlayout_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_weight="1"
      android:clickable="true"
      android:paddingBottom="3dp"
      android:paddingLeft="10dp"
      android:paddingRight="3dp"
      android:paddingTop="10dp&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and the code I have used to add the border : </p>
  
  <pre><code>GradientDrawable drawable = new GradientDrawable();
  drawable.setShape(GradientDrawable.RECTANGLE);
  drawable.setStroke(1, Color.BLACK);
  relativelayout_main.setBackgroundDrawable(drawable);
  </code></pre>
  
  <p>Any suggestion?</p>