Android ActionBar Backbutton Default Padding
Asked Answered
C

3

14

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?

Cioffred answered 6/1, 2016 at 13:30 Comment(0)
R
2

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.

Rett answered 6/1, 2016 at 13:42 Comment(0)
B
12

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">
Bedazzle answered 29/6, 2017 at 10:16 Comment(0)
R
3

From the Material Design spec, the Toolbar icon padding is 16dp.

See "App bar icon top, bottom, left padding: 16dp"

Republican answered 6/1, 2016 at 13:43 Comment(0)
R
2

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.

Rett answered 6/1, 2016 at 13:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.