正常列表展示:
我们要限制显示的item数量效果:
两个比较不难发现虽然都是能滑动,但是展示在当前页面的列表数量不一样。
最近玩蓝牙有这个需求我才知道这玩意还能限制条目。。。
就是最多展示5,多余的点击跳转展示更多。。。死数据研究中
好了废话不多说,回归正题
感谢大佬:https://blog.csdn.net/unknown_315/article/details/88297132
以上网址亲测了下可以实现的,效果上面。
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Adapter item XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_conte