Search code examples
androidlayoutgridviewandroid-imagehorizontal-scrolling

TwoWay GridView library doesn't work properly. (Horizontal GridView)


I was trying to achieve the following task: Setting an horizontal GridView of images instead of the normal vertical GridView.
I found out that most StackOverflow answers were targetting this library:
https://github.com/jess-anders/two-way-gridview

I first ran the sample project and it resulted in the following:

Screen Orientation - Vertical

Screen Orientation - Horizontal

Here's the xml File of the TwoWayGridView layout:

 <?xml version="1.0" encoding="utf-8"?>
<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"/>

I also tried to link this library into my project, but the results are the same. Each image takes the whole row and the scrolling is vertical instead of horizontal.

What could be the reason for that problem? (Note: I haven't changed anything in the sample project).

EDIT: Here's a ScreenShot when importing the project:

enter image description here


Solution

  • Make sure you are using my version of it and not one of the forked versions. I just downloaded a fresh copy from github and it works fine.