Android: Problems with a Toolbar at the bottom of the screen - android

I am using the newest AppCompat library and replaced the SupportActionBar with a Toolbar, as suggested by the Android developer's blog. I want to display a second Toolbar at the bottom of the screen, that shows an additional Menu from some xml menu resource, but nothing else.
I have two problems with that:
Although nothing but a Menu is displayed (using Toolbar.inflateMenu()), the Menu occupies only a small space on the right side of the toolbar.
The Overflow Action Menu expands to the bottom of the toolbar and is therefore not shown. It should expand to the top.
Here is a screenshot of the bottom Toolbar:
How can I solve those issues without being forced to create custom views for my Buttons?

Related

Left align buttons and FAB on top of BottomNavigationBar

I'm looking at the Material Design specification and see this bottom toolbar which looks good with the so-called End-Fab. https://material.io/design/components/app-bars-bottom.html#anatomy
I currently have a standard BottomNavigationBar with a Fab above, but I would very much like to left align the icons and move the fab down over the bar, as in the images in the link above.
Is it possible to do this and still keep the BottomNavigationBar or should I switch to the Bottom app bar (and rewrite the navigation logic)?
Update:
My question is not about how to align the fab, but rather how to incorporate it the same way as with the Bottom toolbar as in the images in the link above.

how to put a profile image and a searchbar in a toolbar?

I am new to Android development I am building an app but from last three days, I am stuck while making toolbar I am very confused. I want to make toolbar like this
The widget elements in your design are the following from left to right:
Navigation Drawer Indicator
ImageView
SearchView
Toggle
Overflow Menu
These can all be implemented using default widgets. It is not common to put a profile image to the right of the title, but you could do this by putting a custom layout inside the toolbar view.
It is also not common to place a toggle in the action bar, but it is possible using an ActionLayout.

Inline action menu embedded in layout

I'm trying to create an inline menu as part of a layout. In other words, I want a "three dots" menu overflow icon (such as the one in the below example), placed on its own somewhere in my layout, and upon clicking it a standard menu should pop up.
At first I tried embedding a Toolbar from the support library in my layout, and while it does result in the menu overflow icon being shown, it's not ideal for my situation; a toolbar is a wide component intended to include a title, sub-title, icon etc. I only need the menu icon and behavior. Also, I have failed to style the toolbar to my liking, including getting rid of the quite large margin around the menu overflow icon. It would make more sense to use a simpler component for just the menu then trying to make a Toolbar fit into my layout.
I know that Toolbar internally uses an ActionMenuView to implement the menu, so I then tried including an ActionMenuView in my layout, and attach a menu to it from code:
<LinearLayout ...>
<android.support.v7.widget.ActionMenuView
android:id="#+id/menu_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
...
ActionMenuView amv = (ActionMenuView)findViewById(R.id.menu_button);
getMenuInflater().inflate(R.menu.some_menu, amv.getMenu());
amv.setOnMenuItemClickListener(...)
This however only results in an invisible view. When using a Toolbar and writing the equivalent code to attach a menu to it, the menu overflow icon is automatically shown and can be clicked, but when using a stand-alone ActionMenuView I just cannot get it to work.
I even tried to hard-code the width and height to 50dp, and while the view is visible in Android Studio's layout preview window, it's not visible on device (hierarchy viewer shows its height to be zero).
Now, of course I guess I can create an ImageButton with the desired icon and manually implement a menu behavior on it, but surely there must be a simple way to get the existing component working?

Bottom toolbar menu item hint appears at the top

I have an activity with 2 toolbars - one at the top and one at the bottom.
Both are from the Android.Support.V7.Widget.Toolbar package. I am using Xamarin, but that shouldn't be the matter.
When i press and hold an menu item from the bottom toolbar, the action hint will be shown at the top (see screenshot). Is there a way to change that?
This is a known AppCompat bug which has been fixed in version 22.2.1

How to have the options menu over the custom toolbar?

I have a similar problem as found on this specific question.
I'm using a Toolbar from the v7 support library, and a custom layout. If I have no options menu, I have a result similar to what OP has on the question linked above:
However if I have an options menu, it shifts the toolbar a little bit to the left (start). I would like to have it over the toolbar.
Is it possible? The only way I could hack it is by adding a negative right (end) margin to the toolbar layout, however this moves the menu outside of the screen…
Initially, the whole Toolbar contained several views, so they had to share the width with the action menu.
Now instead I wrapped the Toolbar and the other views in a container (a FrameLayout), so that they overlap without sharing the width. I just need to be careful with the margin at the top so that the other views don't overlap with action icons.

Categories

Resources