How to create a border around linear layout like the image below ?
Asked
Active
Viewed 720 times
1

Passiondroid
- 1,573
- 1
- 16
- 28
-
1check this post : http://stackoverflow.com/questions/10457135/how-to-add-border-around-linear-layout-except-at-the-bottom – Vijju Mar 21 '14 at 12:05
-
1What about using a 9 patch? – Phantômaxx Mar 21 '14 at 12:07
-
If you cant see the image here then you can find the image at this link - http://postimg.org/image/i7e1s8k2x/ – Passiondroid Mar 21 '14 at 12:07
-
1This does not conform to Android UI guidelines. Sectioned content should look similar to [this](http://docs.xamarin.com/guides/android/platform_features/fragments/part_3_-_specialized_fragment_classes/Images/preferences_dialog.png). – Eugen Pechanec Mar 21 '14 at 12:08
-
But still i want to create a border like this. – Passiondroid Mar 21 '14 at 12:10
1 Answers
3
use this layout xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#8106a9"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:background="@drawable/lin_bg"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_alignTop="@+id/linearLayout1"
android:layout_marginLeft="28dp"
android:layout_marginTop="-10dp"
android:background="#8106a9"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="Sim Card"
android:textColor="@android:color/white" />
and lin_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
android:width="3dp"
android:color="@android:color/white" />
then i get a layout like below
I hope this will help you

Renjith Krishnan
- 2,446
- 5
- 29
- 53