
To add border to your RelativeLayout, first you need to create a xml resource file in your drawable folder.
Then add the following code to that xml file.
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="5dp" android:color="#757575” /> </shape>
The above code will create black border with 5dp thickness. You can change thickness using ‘width’ parameter and color using ‘color’ parameter in above code.
Sample code to apply above border to a RelativeLayout. Here we assume that the name of above file is border.xml in drawable folder.
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="25dp" android:background="@drawable/border"> </RelativeLayout>