android - AppCompat 是否可以在 API 23+ 上忽略?

标签 android android-xml android-appcompat androidx

我正在从头开始开发一个 Android 项目,该项目至少具有 23 API 级别并使用 AndroidX。当我完成 XML 布局(例如简单的 activity_layout)时,可以在 TextViewandroidx.appcompat.widget.AppCompatTextView 之间进行选择。

  1. TextView 是否针对 AndroidX?
  2. 如果是,我是否可以忽略使用 androidx.appcompat.widget.AppCompatTextView 或其他 AppCompat 组件(如果我的目标是最低 23 API 级别)?

最佳答案

Is TextView targeting AndroidX?

问题不清楚,但是 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 库,则可以忽略此 View 。

关于android - AppCompat 是否可以在 API 23+ 上忽略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57478346/

相关文章:

android - 设置为通知时大图片正在裁剪

android - 自定义 RatingBar 未显示超过 1 星

android - 使用 AppCompat v22.1.0 时如何在 super.onCreate 之前设置 ContentView?

android - 如何以易于维护的格式组合图像、字符串和整数集

Android appcompat 主题始终显示黑色操作栏

java - 如何以编程方式为 Textview 设置 `app:backgroundTint` ?

android - 使用二维码渲染 3D 模型

android - 如何为自定义搜索建议建立建议表?

android - 切换到替代布局时,LoaderManager restartLoader 无法按预期工作

java - 如何将数据字符串存储到数组中