views:

753

answers:

2

I'm trying to create a "scrollable" layout in Android. Even using developers.android.com, though, I feel a little bit lost at the moment. I'm somewhat new to Java, but not so much that I feel I should be having these issues--being new to Android is the bigger problem right now.

The layout I'm trying to create should scroll in a sort of a "grid". I THINK what I'm looking for is the Gallery view, but I'm really lost as to how to implement it at the moment. I want it to "snap" to center the frame, like in the actual Gallery application.

Essentially, if I had a photo gallery of 9 pictures, the idea is to scroll between them up/down AND side to side, in a 3x3 manner. Doesn't need to dynamically adjust, or anything like that, I just want a grid I can scroll through.

I'm also not asking for anyone to give me explicit code for it--I'm trying to learn, more than anything. But pointing me in the right direction for helpful layout programming resources would be greatly appreciated, and confirming if it's a Gallery view I'm looking for would also be really helpful.

EDIT: To clarify, the goal is to have ONE item on screen at a time. If you scroll between one item and the next, the previous one leaves the screen, and the new one snaps into place. So if it were a photo gallery, each spot on the grid would take up the entire screen size, approximately, and would be flung out of the viewable area when you slide across to the next photo, in either direction. (Photos are just an example for illustration purposes)

+1  A: 

This page gives a good summary of the different built in layout objects. From your description a GridView or possibly a TableLayout might work. GalleryView looks to be horizontal only.

drawnonward
+1  A: 

I believe GridView is what you're looking for. Here's a tutorial: http://developer.android.com/resources/tutorials/views/hello-gridview.html

Jeffrey
Thanks for the comment. I'm not sure if GridView can do everything that I'm looking for (specifically "snapping" to center a grid item. i'm sure I could code that in though, but are you aware of any specific views that could help with that?)
Matt D