Skip to content

Instantly share code, notes, and snippets.

@wassim93
Last active May 12, 2021 10:34
Show Gist options
  • Save wassim93/f586c15eb8aa3f1ca6d6c62d28ba4883 to your computer and use it in GitHub Desktop.
Save wassim93/f586c15eb8aa3f1ca6d6c62d28ba4883 to your computer and use it in GitHub Desktop.
add border to layout in android
Basically, you need to create a custom drawable and add it as a background to your layout. example:
Create a file called customborder.xml in your drawable folder:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp"/>
<padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>
<stroke android:width="1dp" android:color="#CCCCCC"/>
</shape>
Now apply it as a background to your smaller layout:
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/customborder">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment