Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between TextView and TextViewCompat

I need to know what actual difference between TextView and TextViewCompat. When we should use TextViewCompat?

like image 505
Ashish Dwivedi Avatar asked Jan 13 '16 09:01

Ashish Dwivedi


People also ask

What is the difference between TextView and AppCompatTextView?

A TextView which supports compatible features on older versions of the platform, including: Allows dynamic tint of its background via the background tint methods in ViewCompat . Allows setting of the background tint using R.

When to use AppCompatTextView?

AppCompatTextView use to provide backwards compatibility for new functions to older versions of Android. thois is not a problem, you can extend whatever you want. Android Studio only warns you that AppCompatTextView is more suitable to be used for compatibility.


2 Answers

In much the same way as other compatibility classes, it exists to provide backwards compatibility for new functions to older versions of Android.

If you compare the two, you will see the difference.

One such example is getMaxLines(). In an ordinary TextView, this requires SDK level 16. TextViewCompat introduces such functions for SDK levels from 4.

like image 135
Knossos Avatar answered Oct 21 '22 12:10

Knossos


define TextViewCompat in developer.android

A TextView which supports compatible features on older version of the platform, including:

Supports textAllCaps style attribute which works back to Gingerbread. Allows dynamic tint of it background via the background tint methods in ViewCompat. Allows setting of the background tint using backgroundTint and backgroundTintMode.

like image 26
Mahdi Mortazavi Avatar answered Oct 21 '22 12:10

Mahdi Mortazavi