Android ActionBar后退按钮默认填充

Jay*_*iyk 7 android android-layout android-actionbar android-toolbar

我创建一个自定义的ActionBar使用RelativeLayoutImageButton左侧以取代它。我已经从Google网站下载了“后退”图标,可以在ImageButton

问题是我需要创建一个“后退”按钮来替换原始的ActionBar“后退按钮”,并且我需要使其与原始ActionBar“后退”按钮完全相同。

我想知道“返回”按钮图像的系统默认填充是什么?

Dib*_*Roy 5

您需要在声明中添加以下几行:

app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
Run Code Online (Sandbox Code Playgroud)

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

例:

<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">
Run Code Online (Sandbox Code Playgroud)


小智 2

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

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

Android API 21 工具栏填充

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