How to have the options menu over the custom toolbar? - android

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.

Related

Is possible have to different menu in Action Bar? (Kotlin)

I have an app, which have an action menu item on the right (2).
I need an ulterior menu in the left(1) or a button in the action bar, is that possible?
I attach a image.
enter image description here
You may create a custom toolbar. The standard height of a toolbar is 89dp.
To create a custom toolbar you should make your activity view container RelativeLayout. Then create a custom toolbar view (it may also be RelativeLayout) which height is 89dp. Then add your toolbar to the main container and set alignParentTop to true. So you have a custom flexible toolbar and you can add any view to it.
This way is very comfortable to use any custom views on your toolbar.
I also faced the same situation of customizing action bar. After a lot of searching I got the solution which is Toolbar.
Checkout: https://developer.android.com/training/appbar/setting-up
I think from now on, you should start using Toolbar as the default action bar for your apps. It provides high level of customization and material design features.

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 create bended Collapsing Toolbar Layout?

How can we create a collapsing toolbar layout like Yahoo News Digest application ?
Have you tried adding app:behavior_overlapTop="50dp" to your scrolling view? (This is the default behavior. Code can be found here.)
Apparently, it should support that attribute to make the scrolling view overlap your app bar.
Start by implementing the square collapsing toolbar as you can find in many other guides and then set that parameter.
If that does not work, you could write your own Behavior I guess, inspiring from the one I linked you (which is the default AppBarLayout behavior that allow the coordinator layout to collapse the top part.
To make the image not square you need to use a semi-transparent image or edit it by code.

Why did Toolbar replace ActionBar?

As of Android L, we have a Toolbar instead of the ActionBar although its usages seems the same. They even made back compatibility for Toolbar via support library.
What was the reason they replaced ActionBar with a Toolbar?
Toolbar was added because UIs have evolved past the limitations of the ActionBar. The main difference is that the Toolbar can be decoupled from an Activity's opaque window decor and placed in your custom layout somewhere. From there, you have the freedom to do some more interesting things with the Toolbar. One common example is growing or shrinking the height based on scrolling.
From the Toolbar Documentation.
A Toolbar is a generalization of action bars for use within
application layouts. While an action bar is traditionally part of an
Activity's opaque window decor controlled by the framework, a Toolbar
may be placed at any arbitrary level of nesting within a view
hierarchy. An application may choose to designate a Toolbar as the
action bar for an Activity using the setActionBar() method.
Toolbar supports a more focused feature set than ActionBar. From start
to end, a toolbar may contain a combination of the following optional
elements:
A navigation button. This may be an Up arrow, navigation menu toggle, close, collapse, done or another glyph of the app's choosing.
This button should always be used to access other navigational
destinations within the container of the Toolbar and its signified
content or otherwise leave the current context signified by the
Toolbar. The navigation button is vertically aligned within the
Toolbar's minimum height, if set.
A branded logo image. This may extend to the height of the bar and can be arbitrarily wide.
A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content
contained there. The subtitle, if present should indicate any extended
information about the current content. If an app uses a logo image it
should strongly consider omitting a title and subtitle.
One or more custom views. The application may add arbitrary child views to the Toolbar. They will appear at this position within the
layout. If a child view's Toolbar.LayoutParams indicates a Gravity
value of CENTER_HORIZONTAL the view will attempt to center within the
available space remaining in the Toolbar after all other elements have
been measured.
An action menu. The menu of actions will pin to the end of the Toolbar offering a few frequent, important or typical actions along
with an optional overflow menu for additional actions. Action buttons
are vertically aligned within the Toolbar's minimum height, if set.
In modern Android UIs developers should lean more on a visually
distinct color scheme for toolbars than on their application icon. The
use of application icon plus title as a standard layout is discouraged
on API 21 devices and newer.

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

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?

Categories

Resources