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
.
TextView
targeting AndroidX?androidx.appcompat.widget.AppCompatTextView
or other AppCompat
component if I target min 23 API level?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.
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.
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.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With