AppCompatTextView

A AppCompatTextView displays text to the user and optionally allows them to edit it. A AppCompatTextView is a complete text editor, however the basic class is configured to not allow editing.
Required package for AppCompatTextView is androidx.appcompat.widget for androidx

Class hierarchy:
public class AppCompatTextView extends TextView implements TintableBackgroundView, TintableCompoundDrawablesView
java.lang.Object
↳ android.view.View
  ↳ android.widget.TextView
    ↳ androidx.appcompat.widget.AppCompatTextView

We Recommend to use new UI components i.e. androidx components


TextView

A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing
Required package is android.widget for android


Android AppCompatTextView Attributes

Attribute Description
android:id This is the ID which uniquely identifies the control.
android:autoLink It will automatically found and convert URLs and email addresses as clickable links.
android:cursorVisible Makes the cursor visible (the default) or invisible. Default is false.
android: ems It is used to make the textview be exactly this many ems wide.
android:hint It is used to display the hint text when text is empty
android:width It makes the TextView be exactly this many pixels wide.
android:height It makes the TextView be exactly this many pixels tall.
android:fontFamily Font family (named by string) for the text.
android:text It is used to display the text.
android:textColor It is used to change the color of the text.
android:gravity It is used to specify how to align the text by the view's x and y-axis.
android:maxWidth It is used to make the TextView be at most this many pixels wide.
android:minWidth It is used to make the TextView be at least this many pixels wide.
android:textSize It is used to specify the size of the text.
android:textStyle It is used to change the style (bold, italic, bolditalic) of text.
android:inputType The type of data being placed in a text field. Phone, Date, Time, Number, Password etc.
android:textAllCaps Present the text in ALL CAPS. Possible value either "true" or "false".
android:typeface Typeface (normal, sans, serif, monospace) for the text. You can use or more of the following values separated by '|'.

Create AppCompatTextView in Layout xml
<androidx.appcompat.widget.AppCompatTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:text="Hello Text View" />


AppCompatTextView Creating Programatically
package com.theitbulls.uicomponentex;

import android.os.Bundle;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.LinearLayoutCompat;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AppCompatTextView textView = new AppCompatTextView(this);
        LinearLayoutCompat.LayoutParams params = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        textView.setLayoutParams(params);

    }
}


Few attributes example
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <!-- andriod:gravity attribute -->
    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/tv1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Gravity Property Center Horizontal"
        android:layout_gravity="center_horizontal" />

    <!-- andriod:autoLink attribute -->
    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/tv2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ui Componnet tutorial @ theitbulls.com/android"
        android:autoLink="all" />

    <!-- andriod:cursorVisible attribute -->
    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/tv3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Cursor visible example"
        android:cursorVisible="true" />

    <!-- andriod:ems attribute -->
    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/tv4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Cursor visible example"
        android:ems="@android:integer/status_bar_notification_info_maxnum"
         />

    <!-- andriod:hint attribute -->
    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/tv5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:hint="Demo text" />

    <!-- just keep practice like that -->
</androidx.appcompat.widget.LinearLayoutCompat>


We will recommend you to try AppCompatTextView with different attributes of AppCompatTextView in layout xml file as well at programming time to have different look and feel of the AppCompatTextView, Keep practice guys best of luck.