愤怒的小鸟就像滚动菜单 [英] Angry Birds like scrolling menu

查看:126
本文介绍了愤怒的小鸟就像滚动菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你开始愤怒的小鸟,打玩你显示一个带中心线上的图像,一旦点击就可以开始游戏并没有什么水平滚动菜单。我不知道如何给它滚动横向(水平),并显示tappable图像进行菜单simular到这一点?在此先感谢!

When you start Angry Birds and hit play you are shown a horizontally scrolling menu with a centered line of images that once clicked on you can start the game and what not. I was wondering how to make a menu simular to this in that it scrolls sideways (horizontally) and shows tappable images? Thanks in advance!

推荐答案

我会认为你可以做到这一点与<一个href="http://developer.android.com/reference/android/widget/HorizontalScrollView.html">HorizontalScrollView.您Horizo​​ntalScrollView的孩子将与取向的LinearLayout:水平。它将包含ImageViews或ImageButtons。为了实现捕捉大意是一个在愤怒的小鸟有你不得不为你的滚动视图设置onTouchListener(),和ACTION_UP部分里面你会检查hScrlView.getScrollX(),看看哪个图像你是最接近,则调用hScrlView.scrollTo(X,Y),使x参数的图像的布局的x值,你是最接近

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.

编辑:我还没有亲自使用GalleryView但基于本教程好像你很可能得到它的工作方式。它可以处理的捕捉到机械师给你,让你不会有让自己的触摸监听器来做到这一点。林不知道,如果你可以设置图像之间的空间(愤怒的小鸟的图片有s $ P $垫出了不少),在画廊,虽然,我确实知道你可以的,如果您使用的是Horizo​​ntalScrollView和线性或相对布局。

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.

这篇关于愤怒的小鸟就像滚动菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆