如何在android的创建水平的菜单吗? [英] How to create horizontal menu in android?

查看:140
本文介绍了如何在android的创建水平的菜单吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作水平菜单会在屏幕上方打开。
布局是一样的东西之后,

I am working on horizontal menu that will open on top of the screen. Layout is something like following,

|| < ||菜单项目1 ||菜单项目2 ||菜单项目3 || > ||

|| < || Menu Item1 || Menu Item2 || Menu Item3 || > ||

我想把这在屏幕的顶部。它可以有3个以上的菜单
项目,它可以遍历previous和下一个箭头。
我开始喜欢这个,

I want to put this on top of the screen. It can have more than 3 menu item and it can traverse through previous and next arrow. I started with like this,


  • RelativeLayout的(宽度 - FILL_PARENT)

  • RelativeLayout ( width - fill_parent)


  • 图库视图(这里我附加适配器)

有是二的问题,
- 画廊视图包含之前和之后的空间
- 虽然它的滚动的项目被选中

There is two problem, - Gallery view contains the space before and after - While scrolling its item gets selected

虽然它的这种不理想的解决方案。我怎么可以创建自定义
组件这样吗?
任何帮助AP preciated。

Though its not ideal solution for this. How can i build custom component like this ? Any help appreciated.

感谢

推荐答案

如果你想使用一个画廊,你可以,如果你想说减慢一扔或忽略垂直一扔覆盖onFling行为等。

If you want to use a gallery, you can override the onFling behaviour if you want to say slow down the fling or ignore vertical fling etc.

要禁用的空间,有一个API调用 gallery.setSpacing() ...
为了使库不选择,当你丢使用 gallery.setCallbackDuringFling(假)

To disable the space, there is a an api call gallery.setSpacing()... To make the gallery not select when you are flinging use gallery.setCallbackDuringFling(false)

不过,如果你想要的是一个静态菜单,与左右按键滚动,我只是一个子类和的LinearLayout从那里走了。

However, if all you want is a static menu that scrolls with the left and right buttons, I'd just subclass a LinearLayout and go from there.

这篇关于如何在android的创建水平的菜单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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