So I've been trying to implement android.support.v7.widget.Toolbar
in my Activity and to make it look similar to the previously supported split ActionBar.
Here's the XML for my Toolbar:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_btm"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/toolbar_bkgnd"
android:layout_alignParentBottom="true"
app:theme="@style/ToolBarTheme" />
Here's the style for the Toolbar I'm using:
<style name="ToolBarTheme" parent="Theme.AppCompat">
<item name="actionButtonStyle">@style/ActionButtonStyle</item>
<item name="android:actionButtonStyle">@style/ActionButtonStyle</item>
<item name="android:textColor">@android:color/white</item>
</style>
The style for the Toolbar menu buttons, my initial plan was to calculate the minWidth
based on the screen size and then set it for each menu button.
<style name="ActionButtonStyle" parent="@android:style/Widget.Holo.Light.ActionButton">
<item name="android:minWidth">56dip</item>
<item name="android:paddingLeft">0dip</item>
<item name="android:paddingRight">0dip</item>
</style>
And finally, here is what I'm calling in my activity.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_btm);
toolbarBtm.inflateMenu(R.id.menu);
The problem is that the menu items in the bottom Toolbar
are right aligned like this:
However I want them to be evenly spaced like this:
setCustomView()
call that can be used to potentially get the design pattern that would be wanted. And it seems as though theToolBar
class itself also supports multiple custom views on quick glance. Then you should be able to use aLinearLayout
with weights. – Shinymatch_parent
and to have an equallayout_weight
. Have you tried that? – Primatology