Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is AppCompat possible to ignore on API 23+?

I am developing an Android Project from scratch that has min 23 API level and uses AndroidX. When I complete the XML layouts (for ex. simple activity_layout) there is options to pick like between TextView & androidx.appcompat.widget.AppCompatTextView.

  1. Is TextView targeting AndroidX?
  2. If yes, can I ignore using androidx.appcompat.widget.AppCompatTextView or other AppCompat component if I target min 23 API level?
like image 432
vasile Avatar asked Aug 13 '19 13:08

vasile


People also ask

Is an AppCompat widget that can only be used with?

java - AppCompat widget that can only be used with a Theme. AppCompat theme (or descendant) - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

What is AppCompat TextView?

AppCompatTextView widget enhanced with emoji capability by using EmojiTextViewHelper . 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.


2 Answers

Is TextView targeting AndroidX?

The question in not clear but the class androidx.appcompat.widget.AppCompatTextView extends android.widget.TextView.

You can check the official doc.

A TextView which supports compatible features on older versions of the platform.

Also:

This will automatically be used when you use TextView in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

Then.

If yes, can I ignore using androidx.appcompat.widget.AppCompatTextView or other AppCompat component if I target min 23 API level?

You can ignore this view if you are using the androidx.appcompat:appcompat:x.y.z library.

like image 74
Gabriele Mariotti Avatar answered Sep 27 '22 19:09

Gabriele Mariotti


from the standard android documentation for AppCompatTextView:

This will automatically be used when you use TextView in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views.

taken from here : https://developer.android.com/reference/android/support/v7/widget/AppCompatTextView , so yes, you can just use TextView as long as your activity extends AppCompatActivity


As pointed out by @Gabriele Mariotti (thank you to him) you should check out the documentation here https://developer.android.com/reference/kotlin/androidx/appcompat/widget/AppCompatTextView for more information regarding androidx AppCompatTextView documentation specifically.

The androidX documentation states the following regarding an AppCompatTextView:

This will automatically be used when you use TextView in your layouts and the top-level activity / dialog is provided by appcompat. You should only need to manually use this class when writing custom views

an exact duplicate of the standard android documentation.


My initial answer only made use of this : https://developer.android.com/jetpack/androidx/releases/appcompat to check for any known limitations or history regarding androidx AppCompatTextView

I assumed that:

Like the Support Library, AndroidX ships separately from the Android OS and provides backwards-compatibility across Android releases. AndroidX fully replaces the Support Library by providing feature parity and new libraries.

taken from https://developer.android.com/jetpack/androidx would be sufficient to make that assumption, +1 to him for the help :)

like image 41
a_local_nobody Avatar answered Sep 27 '22 19:09

a_local_nobody