Android 自定义操作栏布局未获得正确的宽度

Android 自定义操作栏布局未获得正确的宽度,android,android-layout,android-actionbar,navigation-drawer,Android,Android Layout,Android Actionbar,Navigation Drawer,我试图使用一个自定义布局的行动栏与导航抽屉,但它似乎是宽度不一致 下面是它现在的样子: 由于某些原因,操作栏左侧的宽度没有完全占据 当前在自定义操作栏中使用的项目有:应用程序名称文本视图、微调器某些文本、微调器右侧的图像视图 这就是我的布局xm的样子: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android

我试图使用一个自定义布局的行动栏与导航抽屉,但它似乎是宽度不一致

下面是它现在的样子:

由于某些原因,操作栏左侧的宽度没有完全占据

当前在自定义操作栏中使用的项目有:应用程序名称文本视图、微调器某些文本、微调器右侧的图像视图

这就是我的布局xm的样子:

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <ImageView
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:padding="10dp"
        android:layout_gravity="center_vertical|left"
        android:src="@drawable/someIcon" />

    <TextView
        android:id="@+id/appTextLabel"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:padding="10dp"
        android:text="someAppName"
        android:textColor="#555555"
        android:textSize="24sp"
        android:textStyle="bold" />

    <Spinner
        android:id="@+id/locationSpinner"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="#000"
        android:spinnerMode="dropdown" />

    <ImageView
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_gravity="center_vertical|right"
        android:src="@drawable/location_down_icon" />
</LinearLayout>
不知道这出了什么问题


任何帮助都将不胜感激。谢谢

这是图标空间还是徽标空间

你可以试试

 getActionBar().setDisplayShowHomeEnabled(false);
但是你有ActionBar.DISPLAY\u SHOW\u HOME和ActionBar.DISPLAY\u HOME\u UP的标志,也许它们对你很重要

您也可以尝试设置透明图标

getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

我试过密码了。。不工作。。你认为这个问题可能是导航抽屉的原因吗?我试图删除这些标志,但它仍然是相同的。我对布局和操作条形码进行了编辑。。似乎工作得更好一些,但左侧仍有一些空间。如果您使用的是Drawer,请确保使用AppCompat v21的最新版本。此外,您还可以在样式中将android:homeAsUpIndicator设置为空-这将删除后退箭头,但不要删除整个变形抽屉图标,为此,您必须设置setDisplayShowHomeEnabledtrue;
getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));