Как я могу решить эту проблему при создании переработчика? - PullRequest
0 голосов
/ 15 апреля 2020

Я пытаюсь создать Recyclerview + Cardview с GridLayout, но Android Studio показывает ошибку, мне нужно знать, что здесь не так Изображение, показывающее ошибку, код:

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="120dp"
android:layout_height="190dp"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_margin="5dp"
cardview:cardcornerRadius="4dp">
<LinearLayout
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
<ImageView
  android:id="@+id/book_img_id"
  android:layout_width="match_parent"
  android:layout_height="160dp"
  android:scaleType="centerCrop"
  android:background="#2d2d2d"/>
<TextView
  android:id="@+id/book_title_id"
  android:textColor="#2d2d2d"
  android:textSize="13sp"
  android:gravity="center"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:text="سكر"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

1 Ответ

0 голосов
/ 15 апреля 2020

Используйте app:cardCornerRadius="4dp" вместо cardview:cardCornerRadius="4dp"

cardCornerRadius атрибут находится в приложении

Попробуйте код наподобие:

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="120dp"
    android:layout_height="190dp"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:cardCornerRadius="4dp">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="160dp"
            android:src="@mipmap/ic_launcher_round"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="Android"/>
    </LinearLayout>
</androidx.cardview.widget.CardView>

Надеюсь, это поможет вам

...