二进制 XML 文件第 52 行:错误膨胀类 |对此感到头疼

我正在尝试在我的应用程序中添加刮刮卡(在 Fragment 中),但是每当我打开应用程序时,它都会显示:

android.view.InflateException:二进制 XML 文件第 52 行:二进制 XML 文件第 52 行:错误膨胀类 com.anupkumarpanwar.scratchview.ScratchView

此外,fragment 没有显示,它会自动关闭屏幕

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ScratchCardFragment">

<androidx.cardview.widget.CardView
    android:layout_width="210dp"
    android:layout_height="210dp"
    app:cardElevation="5dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:ignore="UseCompoundDrawables">

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="90dp"
            android:layout_height="90dp"
            android:layout_gravity="center"
            android:layout_marginTop="20dp"
            android:src="@drawable/ic_gift"
            android:contentDescription="@string/todo" />

        <TextView
            android:id="@+id/scratchText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            android:gravity="center"
            android:text="@string/better_luck_next_time"
            android:textAppearance="@style/TextAppearance.AppCompat.Body1"
            android:textColor="@android:color/black"
            android:textSize="22sp"
            android:textStyle="bold" />
    </LinearLayout>

    <com.anupkumarpanwar.scratchview.ScratchView
        android:layout_width="210dp"
        android:layout_height="210dp"
        android:id="@+id/scratchView"
        app:overlay_image="@drawable/scratch"
        app:overlay_width="210dp"
        app:overlay_height="210dp" />

</androidx.cardview.widget.CardView>

</androidx.constraintlayout.widget.ConstraintLayout>

第 52 行是 app:overlay_height="210dp" />

在创建的视图中添加了这个

    scratchView = view.findViewById(R.id.scratchView);
    scratchText = view.findViewById(R.id.scratchText);

    auth = FirebaseAuth.getInstance();
    firebaseUser = auth.getcurrentUser();
    firebaseFirestore = FirebaseFirestore.getInstance();

    String[] Lose = getResources().getStringArray(R.array.Lose);
    Random rand = new Random();
    int n;
    n = rand.nextInt(4);
    scratchText.setText(Lose[n]);

    scratchView.setRevealListener(new ScratchView.IRevealListener() {
        @Override
        public void onRevealed(ScratchView scratchView) {


          Toast.makeText(getcontext(),"Oops! " + scratchText,Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onRevealPercentChangedListener(ScratchView scratchView,float percent) {

        }
    });
wqqweqe 回答:二进制 XML 文件第 52 行:错误膨胀类 |对此感到头疼

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/647.html

大家都在问