Android: creating a scrollable layout

I am trying to create a "scrollable" layout in Android. However, even using developers.android.com I feel a bit lost at the moment. I'm a bit new to Java, but not so much that I feel like I must have problems like this. New to Android is a big problem right now.

The layout I am trying to create should scroll in a "grid" view. I THINK what I am looking for is a gallery view, but I am really lost on how to implement it at this point. I want it to "snap" to the center of the frame, just like in the Gallery app.

Basically, if I had a photo gallery of 9 photos, the idea is to scroll them up / down and side to side using 3x3. No need to dynamically adjust or anything like that, I just want the grid to be able to scroll.

I also don't ask anyone to give me an explicit code for this - I try to learn, more than anything else. But by pointing me in the right direction for helpful linking resources, we would be very grateful and confirm that if I browse the gallery I'm looking for it will be very helpful as well.

EDIT: To clarify, the goal is to have one item on the screen at a time. If you scroll 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 approximate the size of the entire screen, and be thrown out of the visible area when you move to the next photo in any direction. (Photos are for illustration purposes only)

+2


a source to share


3 answers


This page gives a good summary of the various built-in layout objects. From your description GridView or maybe TableLayout might work. GalleryView only looks horizontally.



+1


a source


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



+1


a source


You should check the ViewPager

widget
that is available in the android compatibility pack. I spent time trying to get the Gallery widget to behave correctly, but finally settled on a ViewPager which returned objects instead ImageView

. Works like a charm.

+1


a source







All Articles