I'm planning an app to have lots of menu items in landscape mode. However, the menu implementation by android seems to have some limitations causing menu items to hide even with a lot of empty space. According to them, this is because of design principles:
When contained within the action bar there is a finite maximum of
action items based on the device's density-independent width. The
action items can also not cover more than half the width of the action
bar.
Action bar - ifRoom option leaving too much space
Also:
To override this behavior and have more items, it would be necessary to build a toolbar and have as many buttons as the screen would support. However, I will be reinventing the wheel, because the android menu has a lot of integrations with the device menu button, overflow behavior by collapsing, tooltip by pressing, etc...
Still, I researched some apps and I found that Squid (old Papyrus) does exactly what I seek. It displays far more than what android limits to and it seems to be exactly the android menu behavior but allowing more items.
My question is: What the recommendation to achieve this? Is there a way to overcome the android limitation with a few "hacks" or should I build a whole new custom menu to change a minimal configuration? Can I inflate the android menu and place it somewhere else?
Thanks.
I guess what you need in this situation is to use ActionBar custom view, I don't really know if there is any other way to
do that but i know a custom view will do the job, and by the way it's very easy.
See the example bellow:
onCreate():
final ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.custom_view);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
Custom View:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!-- Your Items -->
</LinearLayout>
Hope this will help.
Related
I'm using this awesome library Dragger to add drag features to my activity, but is there a way to limit the width of the activity when it shows up or dragged..!? I don't want it to fill the entire screen..! kinda like the drawer navigation menu (see the pic below).
I was thinking of Dialog Activity, but it seems to be concerned with dialogs only and won't allow filling the other 3 sides or I not fully understand it..!
Any help?
Activity is not a view, so it does not have a size. Its' layout views do however.
You can try changing their sizes. Or, as it is an animation lib, you can try modifying existing or adding your own animations where views change sizes when moving. You can modify this param:
<item name="android:windowAnimationStyle">#null</item>
This might help you.
Best description for my issue was at
Keyboard layout hiding android action bar?
And I will paste-quote here:
"I have this problem also but the difference is, i have a list above my edittext and can't use a scrolling container. If I use adjustResize when the edittext is focused it appears above the list and the last items from the list get obscured (list is not pushed up). If I don't use adjustResize on the other hand, when the edittext is focused it pushes everything up but the acionbar is hidden and also I cannot scroll to the top of the list. Can someone share a solution for this? "
So
I have a toolbar
then a chat content
and then a bottom bar for sending a message (editText and a button)
Now, when I tap on an ediText, and soft keyb opens up, I do NOT want my toolbar to collapse and hide, but I do want my chat content to scroll up, so above the bottom entry I will see the last messages from chat content (in listView).
I've tried a number of combinations for Activity adjustResize or adjustPan, but none of them was working. Even wrapped toolbar in CoordinatorLayout and AppBarLayout, but still, no results. Either my content gets pushed/scrolled correctly but toolbar hides OR toolbar stays but softKeyboard overlaps last couple of messages.
The solution I share is a workaround. I had implemented a function scroll(), to scroll my content if a new message arrives, so that was one function I implemented before. I was missing the other part and that is, detect when a softKeyboard was open so I can scroll my content.
That was easy to find here on
How to check visibility of software keyboard in Android?
I hope someone will find this workaround useful and sleep at least a couple more hours.
Note:
Animation of sliding content up is not consistent with softKeyboard sliding up. After keyboard is opened, then I do scroll, which is not in-sync. It is just a snap. But I don't care about that until I find a better solution for orchestrating this event using a native Android component or layout.
The easiest and best solution to all of the above is to simply use the following:
listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
Was wondering how you would go about implementing a custom layout for a toolbar popup, the one you get when you press on the settings button.
I need to increase the padding on the top and bottom of the popup, and also add in a custom font here. The only way I can think to do it would be to basically inflate a custom layout here but I'm not sure how it can be done. Most of the documentation I find online about it is just about styling it instead of adding in a new layout.
I thought maybe doing something like:
app:actionLayout="#layout/menu_settings_popup"
Would work, but unfortunately it doesn't. Also trying to set the layout and background in styles didn't
Would appreciate any help with this. Thanks
I think this would be what you need:
https://scriptedpapers.com/2015/02/12/android-action-bar-and-overflow-menu-customization-with-theme-appcompat/
Been trying everything to show the menu item search (searchWidget) in the actionbar. I have a navigationdrawer, which doesn't hide the actionbar items at any time. But still the search item is always at the overflow, even when having a large screen device.
I have tried using always in the showAsAction in the menu item, and even putting the menu item as visible in the onPrepareOptionsMenu method, and calling it when the drawer opens and closes to see if something changed, and still nothing.
I won't post code now, just wondering if someone had the same problem. If necessary I will post code of course.
If you are using regular action bar menu items (API 13+) then you simply need to say -
android:showAsAction="always"
for that menu item in the menu resource.
However, if you are using the compat library - appcompat-v7 for action bar and menu items (API 7+) then you need your app's name as the namespace as -
yourapp:showAsAction="always"
and add the following to menu tag at the top with the android namespace as -
xmlns:yourapp="http://schemas.android.com/apk/res-auto"
I would like to implement the navigation with options like left and right button that are displayed in following URL. I found the Tab Option for android is possible via Action Bar and Tab Host Control. But I can not find the option with those two button actions.
Navigation in a UItoolbar in iOS
I also tried this by using Linear Layout and horizontal Scrollview concepts but the UI are not comfort as i wish . So If you find Anything Kindly do the needful.
If you want useing SlideNavigation use this library as i used this in my app for create Navigation SlideNavigaiton
and if you want Navigation Ontab you can use scrollable tab as you can see in sherlock actionbar sample and on other way you can Hide actionBar and create custom layout with scrollable contetn for your aim
hope to be usefull :)