我想实现RecyclerView
从左到右显示或添加项目,并且当它到达屏幕末尾时,添加的项目将显示在下一行。
不是这样
这是我的代码
<androidx.recyclerview.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="11dp"
android:layout_marginEnd="11dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="horizontal"
tools:itemCount="10" />
我也尝试使用StaggeredLayoutManager
和Vertical
方向(正如我所说,我想从左到右添加项目),但我不想使用Span
像Grid
一样对齐项目。另外,“列数”不是固定的,可能取决于屏幕大小。
感谢您的帮助,谢谢!
文档有点误导,但我已经成功使用com.google.android.material.chip.ChipGroup
,其中包含ViewSwitcher
的列表。作为记录,它还使用了MaterialButton
列表。
它确实具有您想要的UI行为,但是与RecyclerView
不相关,因此如果您期望使用相同的API,则必须进行一些编码,我建议您扩展自己的MyWrappableView: ChipGroup