Android ActionBar返回按钮默认内边距

14
我正在使用RelativeLayout创建自定义的ActionBar,在左边放置一个ImageButton以替换它。我已经从谷歌网站下载了返回图标来用于这个ImageButton
问题是,我需要创建一个返回按钮来替换原来的ActionBar的返回按钮,而且我需要它与原来的ActionBar的返回按钮完全相同。 我想知道系统默认对于返回按钮图像的填充是多少?
3个回答

12
你需要在声明中添加如下行:

以下是示例:

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">

3
根据Material Design规范,工具栏图标内边距为16dp。
请参考“应用栏图标上、下、左内边距:16dp”。

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接