I am creating a custom ActionBar
using a RelativeLayout
with an ImageButton
to the left to replace it. I have downloaded the Back icon from google's website to use on the ImageButton
The problem is that I need to create a Back button to replace the original ActionBar
's Back Button, and I need it to be exactly identical to the original ActionBar
's back button.
I am wondering what is the system's default padding for the Back button image?
You need to add following lines in the declaration as below:
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
You may adjust the spacing by tweaking around the above data.
Example:
<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">
From the Material Design spec, the Toolbar icon padding is 16dp.
See "App bar icon top, bottom, left padding: 16dp"
Well, I think the default value of contentInset is 16 dp (left & right)
For more info: (search content inset in this) https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/dimens_material.xml
Android API 21 Toolbar Padding
I hope this answers you question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With