Is it possible to have two different menu bars with ActionBarSherlock: one at the top and one at the bottom of screen? I have seen it in many apps, including some system apps, but can't find the appropriate solution. Note that I want to work with both bars like with menus, not just write custom layout and work with simple views, and use them in several Activities in my app.
Is it possible to have two different menu bars with ActionBarSherlock: one at the top and one at the bottom of screen?
Use android:uiOptions="splitActionBarWhenNarrow" on your <activity> or <application> in the manifest.
Related
First sry for my amateur question
When we want to make an Actionbar, we can use AppCompat or libs(like ActionBarSherlock & ...), and when we want just add any widget(like Button-ImageView & ...), we have to add a lot of codes...
But we can create vertical layout (height:50dip) in all of Activities and use it as the Actionbar...(It's very simpler than use standard ActionBar)
I mean is: why we shouldn't do this...?
thanks... :)
ActionBar comes with a useful API, which allows you to add an app/menu icon to the left, and title, tabs, and action icons, as well as skinning options via themes, in a way that looks consistent across all your Activities and Fragments.
ActionBar also behaves (mostly) gracefully across different devices formats, keeping icon, title and action items in a uniform layout, while hiding excess action icons into a menu on the right. If you develop your custom implementation, you need to test that it doesn't break across Android versions and devices.
When in some apps, there are those 3 dots in the top right of the app, on the action bar (not the home buttons), which allow for more options. In my app I have on, but I do not know how to make it do a method when it is clicked. Do I use android:onClick="METHOD_NAME ? Or do I need to setup a button variable in my activity class and setup and onClickListener? I have already tried both but I may be doing something wrong.
That three dots are the menu in the action bar. They are always shown on devices without a menu key.
See also the documentation for more details.
Three dots are called Overflow(very aptly named) and to use them you need to use ActionBar which is the top long, horizontal bar showing icons, other buttons along with the Overflow button.
Now in some devices where there is no physical menu button you will always see Overflow button.
Go through Docs and tutorials related to ActionBar but keep one thing in mind that ActionBar is only available for devices with android above HoneyComb. For android devices below 3.0 such as GingerBread or Froyo you will have to use compatibility libraries, so that will be an additional task.
And most notable libraries for this purpose are ActionBarSherlock and AppCompat.
I have implemented a split actionbar as per android documentation, by adding the following line inside the Application tag of my AndroidManifest.xml: android:uiOptions="splitActionBarWhenNarrow". This has worked, the buttons that appear on the bottom action bar appear in a different fashion to various examples I have seen across the internet and I do not know why.
I have seen many examples on the internet appear like this:
However, the buttons on my bottom action bar appears like this:
How can I space them out so they have the same layout as the first example?
If it renders like this, it's because your screen is larger than the examples you've seen. On your device, I guess the buttons would be too large if they filled all the space.
If you try with 5 buttons, they may suddenly fill all the space available. It really depends on the screen width.
Anyway, developers have almost no control over the layout of the split action bar. That's why several popular apps don't use the split action bar at all but use a custom layout instead (since this bar isn't really hard to reproduce).
On Android Ice Cream Sandwich the GMail App has in the thread view, email headers with a action-bar-like layout. As you can see in the screenshots in portrait mode a header has only 2 icons and the remaining actions are hidden in an overflow menu. In landscape mode all actions are visible. The "real action bar" is at the top. How can you create additional bars like that?
This is part of the application, not the system. This functionality is not provided by the SDK, but you could take the system action bar source code and use as a model/inspiration to integrate in your app. Ultimately, it's just a layout with some icons/buttons you click on. If you provide different layouts for portrait and landscape mode, you can achieve something similar.
It has been long time, but if you are still looking for answer, I believe it is done via SplitActionBar.
To enable split action bar, simply add
uiOptions="splitActionBarWhenNarrow"
to your
<activity> or <application> manifest element.
you can find the information provided in Android Documentation
http://developer.android.com/guide/topics/ui/actionbar.html
I’ve created a bottom menu and used a relative layout to place it there but I don’t know if I’m going about this the right way. It’s a PNG bar with three images on it one for maps, one for facilities and one for search which all should lead to a three different activities.
How do I make each image a button, I know how to make the whole bar a button, in a webpage you can add an image map and create hotspost with the three links.
How do I do that in an Android application?
Cheers,
Mike.
How do I make each image a button
You use three images, and use each in an ImageButton.
Even better would be to follow platform conventions, either:
Using an ordinary options menu, which will automatically be hoisted to your action bar on Android 3.0+, and where you can make some of those be toolbar buttons if you want for immediate clickablilty
Using an action bar library for all Android versions, such as ActionBarSherlock, so you have the same behavior everywhere, including the toolbar buttons where there is room