0

Please see the image and provide me the solution for removing the extra space in between icons. enter image description here

The code in Style.xml file is

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:minWidth">0dp</item>
    <item name="android:paddingLeft">0dp</item>
    <item name="android:paddingRight">0dp</item>
    <item name="android:layout_margin">0dp</item>
</style>

The Code in activity.xml

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp"
        app:contentInsetStartWithNavigation="0dp"/>

The Code in Menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:checkableBehavior="single">
    <item
        android:id="@+id/action_cart"
        android:icon="@drawable/ic_cart"
        android:orderInCategory="4"
        android:title=""
        app:showAsAction="always" />
    <item
        android:id="@+id/action_home"
        android:icon="@drawable/ic_home_top"
        android:orderInCategory="3"
        android:title=""
        app:showAsAction="always" />
    <item
        android:id="@+id/action_filter"
        android:icon="@drawable/ic_filter"
        android:orderInCategory="2"
        android:title=""
        app:showAsAction="always" />
    <item
        android:id="@+id/action_search"
        android:icon="@drawable/ic_search"
        android:orderInCategory="1"
        android:title=""
        app:showAsAction="always" />
</group>

Please provide me solution that how i can remove that extra space in between icons. Thanks

Pushpendra
  • 1,492
  • 1
  • 17
  • 33
  • is it menu? or custom layout in toolbar? – xbadal Oct 31 '17 at 12:08
  • @xbadal This Menu in the Navigation just see the updated – Pushpendra Oct 31 '17 at 12:09
  • @xbadal No i have problem with icons which at the right side – Pushpendra Oct 31 '17 at 12:21
  • Please check this SO question : https://stackoverflow.com/questions/39843904/how-to-increase-padding-or-margin-between-menu-item-icon-and-title-in-app-toolba – Yasin Kaçmaz Oct 31 '17 at 15:26
  • 1
    I think the closers misunderstood your question. I think you want something like is shown in [this post](https://stackoverflow.com/a/15679629). With appcompat, though, you'd remove the `android` namespace prefix from the `actionButtonStyle` item - `name="actionButtonStyle"`. – Mike M. Nov 01 '17 at 00:29
  • 1
    @MikeM. thanks now it's working for me. – Pushpendra Nov 01 '17 at 05:04

1 Answers1

0

The one which you have is actionbar's default design specification.

Use custom toolbar for overriding the behavior.

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"
    app:contentInsetStartWithNavigation="0dp">

    <!-- your icon goes here -->

 </android.support.v7.widget.Toolbar>

And change the theme to extend from NoActionbar

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

Finally in your activity's onCreate() set the toolbar as actionbar

setSupportActionbar(toolbar);
Samuel Robert
  • 10,106
  • 7
  • 39
  • 60