【发布时间】:2020-08-10 01:14:31
【问题描述】:
我每次运行代码时都会崩溃,我尝试删除 CardView 代码,但它不再崩溃了。你能帮帮我吗,因为我是这个环境的新手,目前我正在做一个项目,我对 cardView 代码做错了吗?谢谢
<?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>
【问题讨论】:
-
请您告知错误,您将在 android studio 底部的 logcat 中获取它们,我也想知道如果您提供任何约束,为什么要使用约束布局它指导孩子
标签: java android crash cardview