How to create a border around linearlayout in android

Blog Thủ Thuật
1 min readMay 18, 2019

--

How to create a border around linearlayout in android

Today i am a example border around linearlayout android.

use this layout xml.

<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” />

create file in drawable bg_custom.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” />

Tags: border around linearlayout in android, custom border around, custom linearlayout android

--

--