如何在android中创建水平菜单?(How to create horizontal menu in android?)

编程入门 行业动态 更新时间:2024-10-27 22:22:44
如何在android中创建水平菜单?(How to create horizontal menu in android?)

我正在处理将在屏幕顶部打开的水平菜单。 布局类似于以下内容,

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

我想把它放在屏幕上方。 它可以有超过3个菜单项,它可以遍历上一个和下一个箭头。 我是这样开始的,

RelativeLayout(width - fill_parent)

图库视图(此处我附加了适配器)

有两个问题, - 图库视图包含之前和之后的空间 - 滚动其项目时会被选中

虽然它不是理想的解决方案。 我该如何构建这样的自定义组件? 任何帮助赞赏。

谢谢

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

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

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 ( width - fill_parent)

Gallery View ( Here i appended adapter )

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

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

Thanks

最满意答案

如果你想使用一个图库,你可以覆盖onFling行为,如果你想说减慢投掷或忽略垂直投掷等。

要禁用该空间,有一个api调用gallery.setSpacing() ...要在您投掷时不选择使用gallery.setCallbackDuringFling(false)

但是,如果你想要的只是一个用左右按钮滚动的静态菜单,我只是将LinearLayout子类化并从那里开始。

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.

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)

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.

更多推荐

菜单,item,screen,电脑培训,计算机培训,IT培训"/> <meta name="description&qu

本文发布于:2023-08-06 05:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1445299.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:菜单   水平   如何在   android   menu

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!