1

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

idish
  • 3,190
  • 12
  • 53
  • 85

3 Answers3

3

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.

Jess Anders
  • 968
  • 1
  • 8
  • 11
  • Ah.. Real weird. I downloaded your version twice. Ran the sample and same issue.. ><. – idish Jul 09 '13 at 14:27
  • What device are you running it on? – Jess Anders Jul 09 '13 at 21:10
  • I tried it on 2 devices - Xperia S and Samsung Captivate. Anyways I will try it again tomorrow and let you know. Thanks for you help. – idish Jul 09 '13 at 21:18
  • Alright, OK. I downloaded your project again. I imported the two-way gridview folder into eclipse and I get such an error: Unable to get system library for the project. and if I try to solve it, it just get worse. I think I'm not adding the project as I should maybe? could you tell me how can I run the sample properly please? – idish Jul 11 '13 at 13:48
  • I'm running out of time =/. If your library won't work for me I'll have to use the normal vertical GridView. It is very important for me. Thanks :) – idish Jul 12 '13 at 12:13
  • Maybe you don't have the target sdk it is using in the manifest? try changing that to the sdk library versions you have installed. – Jess Anders Jul 12 '13 at 19:15
  • No, I was importing your project and trying to run your sample. I didn't even started to integrate my project with your library. I'm trying to get the sample to work now. – idish Jul 12 '13 at 20:26
  • 1
    exactly, the sample has an AndroidManifest file that specifies a target api of level 17. If you don't have those libraries installed, you won't be able to compile. Try changing that number to an api version you have installed, or install version 17 of the libraries from the sdk manager. – Jess Anders Jul 12 '13 at 20:45
  • I edited my post with a ScreenShot of what happens, I changed the min sdk and target sdk as well but same issue. – idish Jul 12 '13 at 20:57
  • 1
    Ah, I think it is saying it's not finding your Java 1.6 sdk. You should find that in your project configuration and fix it to point tor you java sdk – Jess Anders Jul 12 '13 at 21:34
  • Thank you very much! it works :) I had to install version 17 SDK – idish Jul 13 '13 at 17:39
  • And does it exhibit the same problem as the screen shot in your original question? – Jess Anders Jul 13 '13 at 18:53
  • can you click on the images in the two-way-gridview? – marienke Aug 06 '13 at 09:02
  • Would appreciate a look here: http://stackoverflow.com/questions/18076104/android-twowaygridview-onitemclicklistenter-not-working – marienke Aug 06 '13 at 09:15
  • @Jess Anders, it it working only if SDK set to the latest one, the target? And, How do I set this library? – David Dimalanta Sep 03 '13 at 08:37
  • 1
    The lag is probably caused by your adapter loading/building the views along with garbage collection. Look for inefficiencies there. – Jess Anders Dec 30 '13 at 00:13
  • @JessAnders I am wondering if its possible to fill data from right to left while scrolling vertically and stackfrombottom is false. – Dmila Ram Apr 11 '16 at 09:41
0

If you are having problems getting the spacing correct using the values in xml, you could try looking at the following tutorial:

http://spragucm.wordpress.com/2013/11/17/android-horizontal-and-vertical-gridview-tutorial/

I specifically wrote it because the two-way-gridview items wouldn't space evenly and they wouldn't fill the row/column. The example code in my tutorial lets you set column and row number and everything else is done for you so that the child fills a row/column with some padding between items.

Chris Sprague
  • 3,158
  • 33
  • 24
0
  app:stretchMode="columnWidth"
  app:scrollDirectionPortrait="horizontal"
  app:scrollDirectionLandscape="horizontal"
Dev Gurung
  • 1,290
  • 14
  • 16