• Have Any Question?
  • contact@eitworld.com

TextView in Android

  • In android development, message is displayed using the TextView.
  • In android, if we want to display any message on the screen, then we have to use the text view.
  • In other programming, label is used to display the message.
  • Here TextView is similar to the Label.
  • In android, three types of TextView are available in Palette as shown in below diagram:


  • In android, TextView is available in Form Widgets.
  • Here three types of text view shown in figure: Large, Medium, and Small.
  • Whenever we want to use, then we have to drag and drop it on the screen or activity.
  • When we want to use TextView in the Java file then first we have to register that TextView in the java file.
  • To use the TextView in java file, we have to provide the unique id to the TextView and we have to register it by using the TextView’s object.
  • There are several properties of the TextView which are as follows:


  • In the above diagram, we can see the several properties of the TextView.
  • Using these properties, we can provide the colorful message using the android:TextColor attribute.
  • Here we can specify the text size using the android:textSize attribute.
  • To apply the more effects on the text, we have to just enter the values in the properties window.
  • Below is the demo of the TextView:
<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
tools:context=”.NewMainActivity” ><TextView
android:text=”Welcome to new activity”
android:textStyle=”bold” />


  • In the above xml file, we have used the relative layout, and we have used a text view.
  • We have applied some effects on the text as shown in the xml file.
  • Here android:layout_width is used to specify the width of the TextView.
  • Here android:layout_height is used to specify the height of the TextView.
  • Here android:layout_msrginTop is used to specify the margin from the top of the TextView.
  • Here android:text is used to specify the message that we want to see on the activity.
  • Here android:textSize is used to specify the size of the text on the screen.
  • Here android:textStyle is used to specify the style of the TextView, here we have used the bold style to show the message on the screen.
  • The screen looks like as follows:


  • The java file is shown below:
package com.example.helloandroid;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class NewMainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.new_main, menu);
return true;

Real Time Web Analytics