It's typical for android apps that if actionbar takes more than 50% of screen width, it moves menu to bottom of screen. Obstacle is that it removes titles too no matter if they would fit or not.
In screenshot below you see comparison of same app run in 480x854 vs 320x480 screen. You can see that it moves menu in smaller screen but removes titles as well despite of that they would fit fine there.
I'm using ActionBarSherlock. According to it's creator The only way to display both would be to use a custom view in the action item that contained both an icon and text.
Can some of you folks give simple example of how to do this? I'm interested only in forcing showing titles, nothing fancy. There is nothing unusual in my app, but if you need sample source codes, I can provide them for you.
You can see that it moves menu in smaller screen but removes titles as well despite of that they would fit fine there.
AFAIK, the bottom portion of the action bar never shows titles.
Can some of you folks give simple example of how to do this?
Add an android:actionView element to your <item> in your <menu> resource, pointing to a layout file that contains whatever you want your fake menu button to be:
<item
android:id="#+id/add"
android:actionLayout="#layout/add"
android:icon="#android:drawable/ic_menu_add"
android:showAsAction="ifRoom"
android:title="#string/add"/>
In your Java code, after inflating your menu resource, you can call getActionView() on the associated MenuItem to get at this inflated layout and configure its widgets (e.g., call setOnClickListener()). In my case, the widget I want to configure is an EditText:
EditText add=
(EditText)menu.findItem(R.id.add).getActionView()
.findViewById(R.id.title);
add.setOnEditorActionListener(this);
(snippets from this sample project)
Personally, I'd either get rid of the split action bar or leave it display as it does by default.
Related
Is there any way to customize the Android toolbar to show as much as possible menu items.
Because this is depends on the screen dpi to show number of the items.
So what I'm looking for is to fill as much as possible of the items and for the rest to be in the popup menu.
On your menu item use this android:showAsAction="always" to show only icons. This could land you into few issues so using android:showAsAction="ifRoom" could be much better if you have less space and more icons to be showcased to the user on the toolbar.And ifRoom adjusts automatically if there is space left on the toolbar with various screens as well as with the portrait and landscape views perfectly fine.
I am working on an Android application and have to code up the following design for one of the screens:
(Ignore the yellow stuff, I have just masked the Logo and the App-specific information for now)
My question is: How do I design this particular type of screen? The top pane is akin to an ActionBar in Android. However, when any button on the top pane is hit, this custom "popup" having a rectangular form with a small arrow on top pointing towards the button is display and does not interrupt the current/main activity.
I have looked around, but still dont understand how to accomplish this.
Any thoughts? Thanks!
You can use the native Action Bar along with the icons.
The only problem is if you want to show them all at once.
Some icons may be hidden depending on the size of the phone.
As for the custom pop-up, the toast feature is available to do that.
It is quite easy to adjust the position of toasts and customise toasts :
Customisation of toasts: http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView
Changing postion of toasts: How to change position of Toast in Android?
I am developing a simple four-action app for Android 3.2. I want all the menu items to appear in the action menu on a single line. (At the moment they appear as a 2x2 grid. I want a 1x4 grid.)
To achieve this I would like to:
remove the text and display only the icon
I have tried removing the android:title attribute, but the empty space for the text remains
minimise the width of the items, so that they all fit in one row (this may not apply to literally all screen sizes, but in my case I can see that the icon images could fit on my emulator screen)
How can I achieve this?
this is just a guess , but it seems like a thing that android won't support out of the box , since there are many different screens out there , and some won't have enough space for all your buttons (you have 4 , but imagine someone who wishes 10 instead) and google won't like it that the user will be frustrated when trying to click the tiny action buttons.
if you want, you can always create your own customized action bar , which would have any behavior you wish .
As the title suggests, I have an Android 4.0 Tablet app, that uses the Actionbar and tab mode.
If I add any more than 4 or 5 tabs to the action bar, a dropdown list is created instead. I have read the documentation, which states, "Note: In some cases, the Android system will show your action bar tabs as a drop-down list in order to ensure the best fit in the action bar."
Was just wondering if it is possible to override the default behavior and get the actionbar to scroll the items? The design document http://developer.android.com/design/patterns/actionbar.html talks about scrollable tabs, but I can't seem to find any information on them other than in the design document.
I have been struggling to get this to work. However, after playing with ActionBarSherlock, the solution is infuriatingly easy. If you download the sample Styled source and look in the MainActivity class, you can see it create and add the tabs, and beneath that:
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
I had called these BEFORE adding the tabs, and my tabs had been turned into a drop-down list. Turns out, all you need to do is call them after adding the tabs instead to keep the scrolling tabs.
Read the "Adding an Action View" section from http://developer.android.com/guide/topics/ui/actionbar.html
An action view is a widget that appears in the action bar as a substitute for an action item's button.
You can use HorizontalScrollView as action view by specifying
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/mytabwidget"
android:title=""
android:icon="#drawable/ic_launcher"
android:showAsAction="always"
android:actionViewClass="android.widget.HorizontalScrollView" />
</menu>
Get reference to this HorizontalScrollView in public boolean onCreateOptionsMenu(Menu menu)
Define a RadioGroup with some RadioButton where each RadioButton when selected, will update its associated tabs contents. Now add this RadioGroup to HorizontalScrollView which you will get in public boolean onCreateOptionsMenu(Menu menu)
You can use selectTab(ActionBar.Tab tab) or some other equivalent method to update tabs contents.
You can change the look of RadioButton by setting android:button to transparent image and then setting some StateListDrawable with states checked, selected and normal..
See below screen I got using this method.
In above image, each RadioButton when checked, selects different tab.
Have you checked out the Honeycomb Gallery sample app in the SDK? It might have what you are looking for. Install it on an ICS non-tablet device to see the scrollable tabs. A tablet has too much screen space for it to scroll.
http://developer.android.com/resources/samples/HoneycombGallery/index.html
The UI works the way it is for a reason. It is extremely confusing to have a scrollable set of tabs. There is a good chance that it won't be clear at all that there are more tabs available on the right, and the user will never know they can scroll the tabs to get to more features.
I recommend sticking with how the platform is designed to work. It generally does things for a reason.
In the Honeycomb ActionBar, I am trying to determine the position of the icons that appear as my ActionBar's 'showAsAction' options. Several of my icons are set to appear only if there is room. I want to include helpful comments under each icon when the application is first run. To properly position the comments , I need an idea of where these icons are.
I have called getActionBar() from the activity and the icons don't appear in the ActonBar's View. I know I can get a handle on the Menu Item through the onPrepare and the onCreate for the OptionsMenu, but they don't contain any positioning information since the ActionBar has not been rendered. Any ideas? I have also explored the onMenuVisibilityListener, but the ActionBar at that point still does not contain any information that I can use to calculate the relative positions of the option menu icons.
If there is a way to also just determine which actionbar items are actually appearing, I can calculate where to place things too.
I want to include helpful comments under each icon when the application is first run.
Then load a different menu XML resource on the first run, one that has withText along with ifRoom for android:showAsAction.
You could make this a configuration option for the user, so the user gets to choose which style to use.
If there is a way to also just determine which actionbar items are actually appearing, I can calculate where to place things too.
Except that you can't actually place anything there. The toolbar buttons take up the full action bar height.