【问题标题】:Android ActionBar Backbutton Default PaddingAndroid ActionBar 后退按钮默认填充
【发布时间】:2016-04-10 14:47:54
【问题描述】:
我正在创建一个自定义ActionBar,使用RelativeLayout 和左侧的ImageButton 来替换它。我已经从 google 的网站下载了返回图标,以便在 ImageButton 上使用
问题是我需要创建一个返回按钮来替换原来ActionBar的返回按钮,并且我需要它与原来ActionBar的返回按钮完全相同。
我想知道系统对后退按钮图像的默认填充是什么?
【问题讨论】:
标签:
android
android-layout
android-actionbar
android-toolbar
【解决方案1】:
您需要在声明中添加如下几行:
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">