Thursday, 17 May 2018

How to Make border of Textview or Button or Layout in Android

- To Make one xml file inside drawable folder name is list_border.xml(drawable/list_border.xml)

 <?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="0dp"></corners>
    <padding
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />
    <stroke
        android:width="1dp"
        android:color="@color/register_edit_border" />

    <solid android:color="@android:color/white" />
</shape>

- Apply above xml file in Textview or Button or Layout as a Background

Ex -    <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="0.85"
                android:gravity="center"
                android:text="Test Click Me"
                android:background="@drawable/list_border"
                android:textColor="@android:color/white"
                android:textSize="18dp" />

No comments:

Post a Comment