Android 操作栏后退按钮默认填充

Android ActionBar Backbutton Default Padding

我正在创建自定义 ActionBar,使用 RelativeLayout 和左侧 ImageButton 替换 。我已经从 google 的网站下载了返回图标,以便在 ImageButton

上使用

问题是我需要创建一个后退按钮来替换原来的 ActionBar 的后退按钮,我需要它与原来的 ActionBar 的后退按钮完全相同.

我想知道后退按钮图像的系统默认填充是什么?

嗯,我认为 contentInset 的默认值是 16 dp(左右)

更多信息:(搜索内容插入此处)https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/dimens_material.xml

Android API 21 Toolbar Padding

我希望这能回答你的问题。

Material Design spec 开始,工具栏图标内边距为 16dp。

见"App bar icon top, bottom, left padding: 16dp"

您需要在声明中添加以下行,如下所示:

app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"

您可以通过调整上述数据来调整间距。

示例:

<android.support.v7.widget.Toolbar
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/toolbar"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:minHeight="?attr/actionBarSize"
  android:theme="@style/ToolbarTheme"
  app:titleTextAppearance="@style/Toolbar.TitleText"
  app:titleTextColor="@android:color/white"
  app:contentInsetLeft="0dp"
  app:contentInsetStart="0dp"
  app:contentInsetStartWithNavigation="0dp"
  app:popupTheme="@style/ThemeOverlay.AppCompat.Light">