0

i want to change the position of items of toolbar but im not found gravity


i hava menu_main.xml

 <menu xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
 tools:context="haythamayyash.myapplication.MainActivity">
  <item
    android:id="@+id/action_settings"
    android:orderInCategory="2"
    android:title="@string/action_settings"
    app:showAsAction="never"/>


<item
    android:id="@+id/backbutton"
    android:orderInCategory="1"
    android:title="back"
  android:icon="@drawable/ic_action_name"
  app:showAsAction="ifRoom"


    />


   </menu> 

and i have activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout          xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="haythamayyash.myapplication.MainActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"

 />


</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_dialog_email" />

      </android.support.design.widget.CoordinatorLayout>

the items appear on the right side on the toolbar by default, how can i change the position of items from right to left ?

  • have you tried this - http://stackoverflow.com/questions/29807744/how-can-i-align-android-toolbar-menu-icons-to-the-left-like-in-google-maps-app – Shadow Droid Aug 21 '16 at 12:54

1 Answers1

0
app:showAsAction="never"

This will make the option hidden. It will be shown only when you click on the menu icon(3 dots on right top of the screen) or menu button of the phone.

app:showAsAction="always"

This will display the option always at the navigation bar.

android:orderInCategory="1"

This will decide the position/order of the option

Dulaj Atapattu
  • 448
  • 6
  • 23