Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ActionBar Backbutton Default Padding

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?

like image 582
JayVDiyk Avatar asked Jan 06 '16 13:01

JayVDiyk


3 Answers

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">
like image 137
Dibyendu Mitra Roy Avatar answered Oct 24 '22 01:10

Dibyendu Mitra Roy


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

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

like image 3
akodiakson Avatar answered Oct 24 '22 02:10

akodiakson


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.

like image 2
kishorepatel Avatar answered Oct 24 '22 02:10

kishorepatel