How to Add One Side Left Border to TextView in Android using XML

June 05, 2018 , , 0 Comments

One side border is most probably used to show text into Flag view. Using the one side border we could make the TextView more good looking. So here is the complete step by step tutorial for How to Add One Side Left Border to TextView in Android using XML.


How to Add One Side Left Border to TextView in Android :


Code for MainActivity.java file.


package com.android_examples.onesidebordertextview_android_examplescom;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Code for activity_main.xml layout file.



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context="com.android_examples.onesidebordertextview_android_examplescom.MainActivity">

android:layout_width="fill_parent"
android:layout_height="100dp"
android:text="This is Sample TextView Text."
android:background="@drawable/text_style"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="12dp"
android:textSize="20dp"
android:textColor="#000"
/>


Code for text_style.xml file.



















Screenshot :



The post How to Add One Side Left Border to TextView in Android using XML appeared first on Android Examples.

siddharth makadiya

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 comments:

Popular Posts