V7 Menu Toolbar Options Menu Item on the Right - How to Add Margin

I use android.support.v7.widget.Toolbar in my activity.

I added it to my layout for the action as follows:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/add_contact_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="@color/colorPrimary"
        android:elevation="6dp"
        android:title="@string/add_contact_toolbar_title"
        android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>


</RelativeLayout>

I am inflating the options menu in onCreateOptionsMenu activity, and I am inflating my menu.xml:

<menu
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/add_contact_optionmenu_save"
        android:title="@string/add_contact_optionmenu_save"
        app:showAsAction="always"/>
</menu>

But, unfortunately, the element looks too far to the right and too small:

enter image description here

How can I make it appear, as in all other applications? More, and with more right border?

Hurrah!

+4
source share
1 answer

To move MenuItema bit to the left of the right edge, you need to set the attribute paddingRightto android.support.v7.widget.Toolbar.

android:paddingRight="20dp"


, <item> App Theme.

<item name="actionMenuTextAppearance">@style/ActionBar.MenuTextStyle</item>
<item name="android:actionMenuTextAppearance">@style/ActionBar.MenuTextStyle</item>


<style name="ActionBar.MenuTextStyle"
       parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textSize">48dp</item>
</style>

, - Material Design. , icon save, .

0

Source: https://habr.com/ru/post/1613223/


All Articles