Android 布局报错:ConstraintLayout 无需使用特性
根据你提供的布局文件,我发现你使用了ConstraintLayout作为根布局,但是在布局中并没有使用到ConstraintLayout的特性。因此,你可以将根布局改为LinearLayout,如下所示:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:layout_gravity="end" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
请注意,我只是将根布局从ConstraintLayout改为LinearLayout,并没有修改其他部分的代码。这样修改后,你应该可以解决报错问题了。如果还有其他问题,请随时告诉我。
原文地址: https://www.cveoy.top/t/topic/RdU 著作权归作者所有。请勿转载和采集!