Add border to RelativeLayout(or any view) in Android

Screen Shot 2016-08-18 at 3.56.16 PM
relativelayout with border


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"?>

    android:color="#757575” /> 

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s