android - 此处不允许使用元素 TextViewCompat

标签 android android-layout android-support-library textview

我正在尝试根据此 article 在我的应用程序上使用 TextViewCompat 来支持较旧的 Android 版本来自 Android 文档。

但是我在 Android Studio 上遇到了这个警告:

Element TextViewCompat is not allowed here This inspection highlights unallowed XML tags in Android resource files and AndroidManifest.xml

我做错了什么?

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.841"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.87" />

    <TextViewCompat
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        android:textSize="120sp"
        android:text="10 min"
        app:layout_constraintBottom_toTopOf="@+id/button"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

最佳答案

使用android.support.v7.widget.TextViewCompatandroid.support.v7.widget.AppCompatTextView

关于android - 此处不允许使用元素 TextViewCompat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51503801/

相关文章:

Android:LinearLayout 的布局问题

Android ListView 数组中的多列

android - 如何使(矩阵?)转换永久成为 RecyclerView

android - 使用 AppCompat-v7 22 的对话框蒙皮会在 api < 21 上产生难看的阴影

Android:xml布局问题

android - 如何在android中制作带有圆角的自定义对话框

android - 在没有 TitleBar 或 ActionBar 的情况下使用 Navigation Drawer

android - fragment 还是支持 fragment ?

android - 识别在 Android 中点击的图像区域?

android - 如何将 CookieManager 持有的 cookie 传递给 Android 中的 Jsoup?