Angry Birds like scrolling menu Angry Birds like scrolling menu android android

Angry Birds like scrolling menu


I would think that you can accomplish this with HorizontalScrollView. The child of your HorizontalScrollView will be a LinearLayout with orientation:horizontal. It will contain ImageViews or ImageButtons. In order to achieve the 'snap to' effect that the one in Angry Birds has you'd have to set an onTouchListener() for your scroll view, and inside the ACTION_UP section you'd check hScrlView.getScrollX() to see which image you are closest to, then call hScrlView.scrollTo(x,y) and make the x parameter the layout x value of the image that you are closest to.

Edit: I have not ever personally used a GalleryView but based on this tutorial it seems like you could probably get it to work that way. And it might handle the 'snap to' mechanic for you so you wouldn't have to make your own touch listener to do that. Im not sure if you can set space between the images(the pictures in Angry Birds are spread out quite a bit) in a gallery though, which I know for sure that you can if you use a HorizontalScrollView and a Linear or Relative Layout.


You can do that using an Gallery, and in your adapter you add the TouchListeners to the ImageViews from each item. This is the best way, cause the Gallery will give support to each image get centered when you are scrolling. With HorizontalScrollView you got only scroll with fling, and the items of your menu will not be centralized.


I haven't been able to find how to do this myself, but this article is a good start:

How can I make a horizontal ListView in Android?