Reputation: 332
I'm trying to make a list with a GridLayout
that has two rows and scrolls horizontally. My problem is that the gridview automatically adds views from top to bottom across the screen (Vertically) instead of filling an entire row before filling the next column (Horizontally).
Images of what I'm talking about:
Upvotes: 0
Views: 727
Reputation: 4907
try this
android:numColumns="auto_fit"
auto_fit Display as many columns as possible to fill the available space.
Upvotes: 2
Reputation: 1180
Take a look at recent-images Library. It provides horizontal gridview(one row). Just add this library dependency and put below code in your xml.
<com.jess.ui.TwoWayGridView
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:columnWidth="70dp"
app:rowHeight="70dp"
app:numColumns="auto_fit"
app:numRows="auto_fit"
app:verticalSpacing="16dp"
app:horizontalSpacing="16dp"
app:gravity="center"/>
Upvotes: 0