0

I created custom Toolbar.I added two images,one in center position and second left position.in xml view,everything is perfect but when i added menu elements in right side in toolbar,toolbar margined right side and image is not left position

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/md_white_1000"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/u_main_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#ff0000"/>

        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_below="@+id/statusBar"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView8"
                    android:background="@mipmap/logo_header"
                    android:layout_centerInParent="true"
                    android:layout_centerHorizontal="true" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/openDrawable"
                    android:background="@mipmap/ic_menu_white"
                    android:layout_centerVertical="true"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true" />
            </RelativeLayout>
        </android.support.v7.widget.Toolbar>


        <FrameLayout
            android:id="@+id/statusBar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/statusBarHeight"
            android:background="@color/u_color" />

    </RelativeLayout>

</LinearLayout>
<LinearLayout android:id="@+id/drawer_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start">

    <LinearLayout
        android:id="@+id/drawer_content"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:orientation="vertical" >

        <include layout="@layout/activity_slider_menu" />
    </LinearLayout>

</LinearLayout>

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

is it a possible to add image center position when i added menu in toolbar?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Georgo
  • 51
  • 1
  • 5

0 Answers0