简体   繁体   English

如何使用水平滚动创建GridView?

[英]How can I make a GridView with Horizontal scrolling?

How can I do that? 我怎样才能做到这一点?

I made android:scrollbars="horizontal" , but it doesn't help 我做了android:scrollbars="horizontal" ,但它没有帮助

You can use this library https://github.com/jess-anders/two-way-gridview to perform horizontal or vertical scrolling in a gridView. 您可以使用此库https://github.com/jess-anders/two-way-gridview在gridView中执行水平或垂直滚动​​。

Some of attributes available are 一些可用的属性是

scrollDirectionPortrait (vertical | horizontal) 
scrollDirectionLandscape (vertical | horizontal)

Here is an example of usage 这是一个使用示例

<com.jess.ui.TwoWayGridView
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#E8E8E8"
android:id="@+id/gridview"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
app:cacheColorHint="#E8E8E8"
app:columnWidth="80dp"
app:rowHeight="80dp"
app:numColumns="auto_fit"
app:numRows="auto_fit"
app:verticalSpacing="16dp"
app:horizontalSpacing="16dp"
app:stretchMode="spacingWidthUniform"
app:scrollDirectionPortrait="vertical"
app:scrollDirectionLandscape="horizontal"
app:gravity="center"/> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM