AppCompat 是否可以在 API 23+ 上忽略?
Is AppCompat possible to ignore on API 23+?
我正在从头开始开发一个 Android 项目,最低 23 API 级别并使用 AndroidX。当我完成 XML 布局(例如简单的 activity_layout)时,可以在 TextView
和 androidx.appcompat.widget.AppCompatTextView
之间选择选项。
TextView
是否针对 AndroidX?
- 如果是,如果我的目标是最低 23 API 级别,我可以忽略使用
androidx.appcompat.widget.AppCompatTextView
或其他 AppCompat
组件吗?
来自 AppCompatTextView 的标准 android 文档:
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.
取自此处:https://developer.android.com/reference/android/support/v7/widget/AppCompatTextView,所以是的,只要您的 activity 扩展 AppCompatActivity
,您就可以使用 TextView
正如@Gabriele Mariotti 所指出的(感谢他),您应该在此处查看文档 https://developer.android.com/reference/kotlin/androidx/appcompat/widget/AppCompatTextView 以获取有关 androidx AppCompatTextView
文档的更多信息。
androidX 文档说明了以下关于 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
标准 android 文档的精确副本。
我最初的回答只使用了这个:https://developer.android.com/jetpack/androidx/releases/appcompat 来检查关于 androidx AppCompatTextView
的任何已知限制或历史记录
我假设:
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.
取自 https://developer.android.com/jetpack/androidx 就足以做出这个假设,+1 给他的帮助:)
Is TextView targeting AndroidX?
问题不清楚,但 class androidx.appcompat.widget.AppCompatTextView
扩展 android.widget.TextView
。
您可以查看official doc。
A TextView which supports compatible features on older versions of the platform.
还有:
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.
然后
If yes, can I ignore using androidx.appcompat.widget.AppCompatTextView or other AppCompat component if I target min 23 API level?
如果您正在使用 androidx.appcompat:appcompat:x.y.z
库,则可以忽略此视图。
我正在从头开始开发一个 Android 项目,最低 23 API 级别并使用 AndroidX。当我完成 XML 布局(例如简单的 activity_layout)时,可以在 TextView
和 androidx.appcompat.widget.AppCompatTextView
之间选择选项。
TextView
是否针对 AndroidX?- 如果是,如果我的目标是最低 23 API 级别,我可以忽略使用
androidx.appcompat.widget.AppCompatTextView
或其他AppCompat
组件吗?
来自 AppCompatTextView 的标准 android 文档:
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.
取自此处:https://developer.android.com/reference/android/support/v7/widget/AppCompatTextView,所以是的,只要您的 activity 扩展 AppCompatActivity
TextView
正如@Gabriele Mariotti 所指出的(感谢他),您应该在此处查看文档 https://developer.android.com/reference/kotlin/androidx/appcompat/widget/AppCompatTextView 以获取有关 androidx AppCompatTextView
文档的更多信息。
androidX 文档说明了以下关于 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
标准 android 文档的精确副本。
我最初的回答只使用了这个:https://developer.android.com/jetpack/androidx/releases/appcompat 来检查关于 androidx AppCompatTextView
我假设:
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.
取自 https://developer.android.com/jetpack/androidx 就足以做出这个假设,+1 给他的帮助:)
Is TextView targeting AndroidX?
问题不清楚,但 class androidx.appcompat.widget.AppCompatTextView
扩展 android.widget.TextView
。
您可以查看official doc。
A TextView which supports compatible features on older versions of the platform.
还有:
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.
然后
If yes, can I ignore using androidx.appcompat.widget.AppCompatTextView or other AppCompat component if I target min 23 API level?
如果您正在使用 androidx.appcompat:appcompat:x.y.z
库,则可以忽略此视图。