重心不在自定义工具栏中工作

时间:2016-07-26 07:16:52

标签: android android-imageview android-toolbar android-relativelayout

我创建了自定义工具栏。我添加了两个图像,一个位于中心位置,另一个位于左侧位置。在xml视图中,一切都很完美但是当我在工具栏右侧添加菜单元素时,工具栏边缘右侧和图像没有留下位置

<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);
}

当我在工具栏中添加菜单时可以添加图像中心位置吗?

0 个答案:

没有答案