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.
<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>
</LinearLayout>
and the code I have used to add the border :
GradientDrawable drawable = new GradientDrawable();
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setStroke(1, Color.BLACK);
relativelayout_main.setBackgroundDrawable(drawable);
Any suggestion?