相关疑难解决方法(0)

Android API 21工具栏填充

如何使用Android SDK API 21版(支持库)删除新工具栏中的额外填充?

我在谈论这张照片上的红色箭头: 在此输入图像描述

这是我正在使用的代码:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:background="?attr/colorPrimary"
        android:padding="0dp"
        android:layout_margin="0dp">

        <RelativeLayout
            android:id="@+id/action_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="0dp"
            android:padding="0dp"
            android:background="#000000">

            <Spinner
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

        </RelativeLayout>
</Toolbar>
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我已将所有相关填充设置为0,但Spinner周围仍有填充.我做错了什么或者我需要做些什么才能摆脱额外的填充?

编辑 有些人质疑我为什么要这样做.

根据材料设计规格,旋转器应距离左侧72dp 降序

我需要中和Google为了正确放置我的微调器而放置的填充: 降序

编辑2

根据Chris Bane在下面的回答,我将contentInsetStart设置为0.对于支持库,您需要使用app命名空间:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

     <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="@dimen/action_bar_height"
        android:background="?attr/colorPrimary"
        android:contentInsetStart="0dp"
        android:contentInsetLeft="0dp"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

我希望这对某人有所帮助,让我困惑了好几天.

android android-toolbar

189
推荐指数
4
解决办法
10万
查看次数

标签 统计

android ×1

android-toolbar ×1