最佳答案
我如何摆脱在新的工具栏与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>
正如你所看到的,我已经将所有相关的填充设置为0,但旋转器周围仍然有填充。我做错了什么,或者我需要做什么来消除额外的填充?
<强>编辑 有些人质疑我为什么要这么做。< / p >
根据材料设计规范,旋转器应从左侧72dp
我需要中和填充谷歌已经放在那里,以适当地放置我的旋转器:
编辑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>
我希望这能帮助到一些人,这让我困惑了好几天。