这个是我上一篇关于的补充,上一篇说的详细一点,戳这里
1.网格布局
(https://blog.youkuaiyun.com/qq_39326574/article/details/98098520)
实现网格视图的关键代码
//定义布局管理器为Grid管理器,设置一行放3个
RecyclerView.LayoutManager layoutManager=new GridLayoutManager(this,3);
//给RecyclerView添加布局管理器
mRecyclerView.setLayoutManager(layoutManager);
下面给出所有代码:
三个类,两个布局文件,七张图。
图片链接:https://pan.baidu.com/s/11aZcT4pKdHkSz3DmBV2z7A
提取码:pl6i
- activity_mian.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
andro