A TextView  is a complete text editor, however the basic class is configured to not allow editing.

TextView Attribute :-
1) android id: provide unique id
2) android text: text toDisplay
3) android gravity:Specifies how to align the text by the view’s x- and/or y-axis when the text is smaller than the view.
4) android hint: Hint text to display when the text is empty.
5) android inputType: The type of data being placed in a text field. Phone, Date, Time, Number, Password etc.
6) android password: password type-number password,text password…etc
7) android textColor: provide color
8) android typeface: Typeface (normal, sans, serif, monospace) for the text.

Example:-

<pre><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp"
    android:background="#000000">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="This is Example of TextView"
        android:textColor="#ffffff"
        android:textStyle="italic"
        android:gravity="center"
        android:textSize="35sp"
        android:layout_gravity="center_vertical" />
    </LinearLayout></pre>

TextView_example

Advertisements