开发者

Scrollable menu bar with left/right arrows

I am looking to create a navigation or menu bar similar to the functionality of the one at the top of the Fox News app. I started to code this myself using a Gallery but I'm not sure how to hide the left and right arrows when they are not needed. I was also wandering if you would have to use images for the menu items or if you coul开发者_如何学Cd just use TextView or buttons so I could change the text without having to modify an image. I have seen this type of navigation on several apps and I tried all types of searches trying to find code examples but I must not be using the correct name for this type of scrollable menu because I couldn't find anything. If anyone has an example or provide a link to an article I would greatly appreciate it.


Look into HorizontalScrollView. It is a Layout that will handle the smooth scrolling and is likely to be much less of a hassle to work with than Gallery for this operation (I just added one for a similar reason).

To handle the left/right, look into setOnTouchListener. I'm not sure if you can get the current scroll position without making a new child class of HorizontalScrollView to access protected methods. There may be other ways, however - I didn't need to add buttons so I didn't investigate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜