有没有办法在 Android Studio 编辑器中将 RecyclerView 的内容预览显示为网格? [英] Is there a way to show a preview of a RecyclerView's contents as Grid in the Android Studio editor?
本文介绍了有没有办法在 Android Studio 编辑器中将 RecyclerView 的内容预览显示为网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我将 RecyclerView 添加到布局时,它以垂直顺序显示为列表视图.我为此使用 tools:listitem
.有没有办法让它在 Android Studio 编辑器中显示为网格而不是列表?
When I add the RecyclerView to the layout, it shows up as a list view in vertical order. I am using tools:listitem
for this. Is there a way, such that it displays as grid but not as list in the Android Studio Editor?
推荐答案
This Worked for me (AndroidX):对于 3 列网格
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvServiceList"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="3"
tools:itemCount="20"
tools:listitem="@layout/row_item_service" />
这篇关于有没有办法在 Android Studio 编辑器中将 RecyclerView 的内容预览显示为网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文