我正在尝试根据此 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
我做错了什么?
<?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.TextViewCompat
或android.support.v7.widget.AppCompatTextView
关于android - 此处不允许使用元素 TextViewCompat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51503801/