Android Textview Border

We cannot set border to textview directly because there is no property to set border for textview.

But we can give background color to Tablelayout & Textview. Using that we can make it look like border for textview.

Android Textview Border Example :-

[sourcecode language="xml"]

<TableLayout android:id="@+id/TableLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#55771B">
<TextView android:text="@+id/TextView01"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3px"
android:layout_marginBottom="3px"
android:layout_marginRight="3px"
android:layout_marginTop="3px"
android:background="#010101"/>
</TableLayout>

[/sourcecode]

Here the tablelayout background color is green & textview background color is black. By using android:layout_marginTop,Right,Bottom,Left as 3px. It will look like a border for textview.

The Output will look like

textviewborder