Home Ask Login Register

Developers Planet

Your answer is one click away!

George Bailey February 2016

Increase spacing between action buttons?

This is my menu.xml at the moment

<menu xmlns:android="http://schemas.android.com/apk/res/android"
        app:showAsAction="ifRoom|withText" />
        android:title="Delete This"

However, the spacing between the overflow menu and the main Save button is pretty small. I'd like to add more spacing.

Here is my styles.xml


    <style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- ... -->
        <item name="android:actionButtonStyle">@style/MyActionButtonStyle</item>

    <style name="MyActionButtonStyle" parent="Widget.AppCompat.Light.ActionButton">
        <item name="android:paddingEnd">100dip</item>
        <item name="android:paddingRight">100dip</item>
        <item name="android:layout_marginRight">100dip</item>
        <item name="android:horizontalSpacing">100dip</item>

    <!-- ... -->


Unfortunately, that style has no effect.

The only thing I can get to work is <item name="android:minWidth">300dp</item>. I am using this for now, but the problem is I am going to have various buttons of different widths, so it would be much better if I could set spacing or padding instead of min-width.

Why are all of my padding rules of 100dip not working, and what should I do instead?


SID February 2016

Found solution, added following lines in styles.xml file and it worked!!

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionButtonStyle">@style/MyActionButtonStyle</item>

<style name="MyActionButtonStyle" parent="AppBaseTheme">
    <item name="android:minWidth">20dip</item>
    <item name="android:padding">0dip</item>

Post Status

Asked in February 2016
Viewed 3,160 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life