先放一个效果图(效果图是用平板截图的,看着比例有点大),
这里我设置了ImageView的固定高度,你们写的时候可以换成
android:layout_height="wrap_content"
下面直接放代码:
1.fragment_find_recommend.xml,这里是在fragment布局文件里面添加一个RecycleView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".fragment.FindRecommendFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recommend_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@color/white"/>
</LinearLayout>
2.recycle.xml,这里是为RecycleView添加内容,包括ImageView和TextView
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
a