Android AppCompatTextView

January 5, 2018 Oclemy Android TextView 0 minutes, 49 seconds

AppCompatTextView is basically a TextView which provides support to older version of the android platform with compatible features of a TextView.

Whenever you use a TextView, android may automatically use the AppCompatTextView.

This is if your project has the necessary support library dependencies.

AppCompatTextView resides in the android.support.v7.widget package.

package android.support.v7.widget;

This class derives from TextView:

public class AppCompatTextView extends TextView{}

Given that it derives from android.widget.TextView, this class inherits TextView's XML attributes. Some of these attributes are inherited by TextView itself from the base View class.

Creating AppCompatTextView.

Not only can you create AppCompatTextView via the XML specifications, but you can also create them programmatically.

To do so you can use the provided public constructors.

Android does provide us three of those:

No. Constructor
1. AppCompatTextView(Context context)
2. AppCompatTextView(Context context, AttributeSet attrs)
3. AppCompatTextView(Context context, AttributeSet attrs, int defStyleAttr)

As for the methods this class does inherit them from other classes like TextView, View and Object.

Comments