2

我正在创建自定义ActionBar使用RelativeLayoutImageButton到左边取代它。我从谷歌的网站上下载返回图标上ImageButtonAndroid ActionBar Backbutton默认填充

问题用的是我需要创建一个返回按钮代替原来的ActionBar的后退按钮,我需要的是完全相同的原ActionBar的后退按钮。

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

回答

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