gridview使用小部件nestedscrollview xml

b4lqfgs4  于 2021-06-27  发布在  Java
关注(0)|答案(1)|浏览(516)

当我在我的项目中添加gridview并使用小部件nestedscrollview xml时,我遇到了这个问题

这段代码我试着从youtube上看到了20多个视频,但同样的问题都是老视频和使用android.support.v4.widget.nestedscrollview在android studio中我不能使用这段在4.2中不支持的是另一段代码

  1. xmlns:app="http://schemas.android.com/apk/res-auto"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. tools:context="Book_Activity"
  6. >
  7. <androidx.core.widget.NestedScrollView
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent"
  10. android:layout_marginTop="10dp"
  11. android:padding="10dp">
  12. <LinearLayout
  13. android:layout_width="match_parent"
  14. android:layout_height="match_parent"
  15. android:gravity="center"
  16. android:orientation="vertical"
  17. >
  18. <ImageView
  19. android:layout_width="125dp"
  20. android:layout_height="170dp"
  21. android:background="#2d2d2d"
  22. android:id="@+id/bookthumbail"
  23. android:scaleType="centerCrop"
  24. ></ImageView>
  25. <TextView
  26. android:layout_width="wrap_content"
  27. android:layout_height="wrap_content"
  28. android:text="Book Title"
  29. android:layout_marginTop="10dp"
  30. android:textSize="18dp"
  31. android:textStyle="bold"
  32. ></TextView>
  33. <TextView
  34. android:layout_width="wrap_content"
  35. android:layout_height="wrap_content"
  36. android:text="Cataloge"
  37. android:background="#edecec"
  38. android:layout_marginTop="10dp"
  39. android:padding="8sp"></TextView>
  40. <TextView
  41. android:layout_width="wrap_content"
  42. android:layout_height="wrap_content"
  43. android:text="Description"
  44. android:layout_marginTop="10dp"
  45. android:textSize="18sp"
  46. ></TextView>
  47. </LinearLayout>
  48. </androidx.core.widget.NestedScrollView>
  49. </LinearLayout>```
0h4hbjxa

0h4hbjxa1#

我选择了主或列表gridview xml文件的问题
一定是这样的:

  1. xmlns:app="http://schemas.android.com/apk/res-auto"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:id="@+id/cardview_id"
  4. android:clickable="true"
  5. android:foreground="?android:attr/selectableItemBackground"
  6. android:layout_width="120dp"
  7. android:layout_height="190dp"
  8. android:layout_margin="5dp" </androidx.cardview.widget.CardView>```

相关问题