5

In my app, there is extra space i dont want between icons and action bar title. The menu button is the default one when one creates navigation activity. and the back arrow i brought by including

 <activity
            android:name=".ShipmentList"
            android:label="Shimpment"
            android:parentActivityName=".MainNavigationActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.mobile.MainNavigationActivity" />
        </activity>

in the AndroidManifest.

enter image description here

enter image description here

Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
aye26
  • 179
  • 1
  • 2
  • 16

2 Answers2

1

You have to use these lines in your toolbar.

app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"

Like this:

<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="?actionBarSize"
    android:background="@color/color18"
    android:elevation="0dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    app:contentInsetEnd="0dp"
    app:contentInsetLeft="0dp"
    app:contentInsetRight="0dp"
    app:contentInsetStart="0dp"
    app:contentInsetStartWithNavigation="0dp" />
Zayn Ali
  • 4,765
  • 1
  • 30
  • 40
-2

On each version upgrade I found some issues with UI changes. This is an issue with android version 24. It happened when I installed it and upgraded my build to it. Maybe this is the new default design by android.. you can build a toolbar instead of the builtin actionBar, then you will be able to padd it as you wish. Or, if you don't mind - you can downgrade to 23.0.3 and appcompat 23.3.0

*By the way- if you will downgrade to 23.0.0 - 23.2.0 you will have an issue with colorState = ContextCompat.getColorStateList(ChatActivity.this,R.color.mycolor); colorstate change on button will have no effect.

any way - this is build.gradle that has a normal padding between home and title in actionBar:

  apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
    applicationId "com.xxxxx.xxxxx.xxxx"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0.7"
}


buildTypes {
    release {
        shrinkResources true
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
repositories {
    maven {
        url 'https://raw.githubusercontent.com/felixb/mvn-repo/master/'
    }
    mavenCentral()
}
productFlavors {
}
}
 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:support-annotations:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'   
}
Udi Reshef
  • 1,083
  • 1
  • 11
  • 14