CardView导致应用程序崩溃(如图所示)

问题描述 投票:0回答:1

每当我运行代码时,我总是崩溃,我试图删除CardView代码,并且它不再崩溃。您是否可以帮助我,因为我是这种环境的新手,并且目前正在从事一个项目,我在cardView代码上做错了吗?谢谢

crashed app

<?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"
    android:background="@drawable/bgapps"
    tools:context=".utama">

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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp">

            <androidx.cardview.widget.CardView
                android:id="@+id/cardCam"
                android:layout_width="120dp"
                android:layout_height="125dp"
                android:layout_below="@+id/cardPupuk"
                android:layout_marginStart="125dp"
                android:layout_marginTop="40dp"
                android:layout_marginEnd="@+id/soilIv"
                app:cardBackgroundColor="#989595"
                app:cardCornerRadius="12dp">

                <ImageView
                    android:id="@+id/camIv"
                    android:layout_width="71dp"
                    android:layout_height="71dp"
                    android:layout_gravity="center"
                    android:src="@drawable/cam" />
            </androidx.cardview.widget.CardView>
        </RelativeLayout>
    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
java android crash cardview
1个回答
0
投票

androidx.cardview.widget.CardView标记中删除以下内容。

 android:layout_marginEnd="@+id/soilIv"

应该是

android:layout_marginEnd="10dp"
© www.soinside.com 2019 - 2024. All rights reserved.