How to break a cardview in multiple columns to make all the content visible in parts?

谁说胖子不能爱 提交于 2019-12-11 09:53:39

问题


I am working on a POS system which needs a delivery screen in which, I have to show all orders in number of columns of list in Cardview.

Something like shown in this image:

I am using cardslib to get the cardsview in my app. Can you please help me to implement this type of layout with cardslib. Or Can you suggest me what will I have to do to have this kinda layout in my app??

I also tried twowayview but couldn't get the idea for breaking the card in multiple columns just like the yellow card shown in above image. Please help me..


回答1:


Finally, I found a workaround for this query. I found a twoway- gridview lib which did help me to add data vertically and scroll horizontally. I used this library by keeping number of rows and columns constants according to screen size and referred them in gridView. Following code is the one which is used from the above library.

<com.jess.ui.TwoWayGridView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/horz_gridview"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#FFC4C4C4"
    app:cacheColorHint="#E8E8E8"
    app:verticalSpacing="-4dp"
    app:horizontalSpacing="0dp"
    app:stretchMode="none"
    app:scrollDirectionPortrait="horizontal"
    app:scrollDirectionLandscape="horizontal"
    app:gravity="center"
    android:layout_gravity="center"/>

Then, Just make a layout to fill each cell of gridView with. You have to create an adapter to fill each cell of the grid with respective content.

I just assumed that each cell of grid will have single line of the view. No multiple lines in a single cell. To show start and end of a card, You can use different background colors to the starting and ending cells.

In short: You have to make a List of data which u have to put it in grid with the help of adapter.

You can refer this tutorial to use above library.



来源:https://stackoverflow.com/questions/31427315/how-to-break-a-cardview-in-multiple-columns-to-make-all-the-content-visible-in-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!