user1302569 user1302569 - 1 year ago 85
Android Question

How can I create a border around an Android LinearLayout?

I have one big layout, and one smaller layout inside of it.

How do I create a line border around the small layout?

Answer Source

Sure. You can add a border to any layout you want. 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="" 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"/>

Now apply it as a background to your smaller layout:

<LinearLayout android:orientation="vertical"

That should do the trick.

Also see:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download