开发者

Customized navigation menu in Android

开发者 https://www.devze.com 2023-02-24 09:50 出处:网络
I\'d like to create a navigation menu in my Android app: a bar always at the bottom of the screen, with 4 choices Home|Categories|Search|F开发者_运维知识库avorites, and the current page highlighted.

I'd like to create a navigation menu in my Android app: a bar always at the bottom of the screen, with 4 choices Home|Categories|Search|F开发者_运维知识库avorites, and the current page highlighted. It seems the options menu can hardly be customized, so I can't use it.

Do I have to add this navigation bar in every layout or is there any better solutions?

Thanks

Julien


It sounds like you're replicating an iPhone interface. As most Android phones have buttons along the bottom of the screen (Home, Back, etc) it's likely to be a bad idea to put navigation there as it's easy to hit the wrong one.

The Google-recommended approach is to use the Action Bar pattern, across the top of the screen, which is very clear, and means your app is consistent with others (look at Twitter, Google Maps, Facebook - they all use the action bar pattern).

From Honeycomb (v3.0) onwards: http://developer.android.com/reference/android/app/ActionBar.html

A simple library to create an Action Bar on any version of Android https://github.com/johannilsson/android-actionbar

To create an action bar that uses that library on versions earlier than 3.0, but uses the official implemention for v3.0+, try this: https://github.com/JakeWharton/ActionBarSherlock

The action bar is highly customisable, but remember that a key to a nice user interface is consistency across the platform, i.e. your app consistent with other apps and the OS.

If you need a navigation with more items or items within a specific page, you can use TabLayout, but for your primary nav, use the action bar, that's what it's for.

Customized navigation menu in Android

Customized navigation menu in Android


Use the TabLayout

0

精彩评论

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