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"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_save"
        android:title="Save"
        android:icon="@drawable/ic_action_save"
        app:showAsAction="ifRoom|withText" />
    <item
        android:id="@+id/action_delete"
        android:title="Delete This"
        android:icon="@drawable/ic_action_delete"
        app:showAsAction="never"/>
</menu>

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

<resources>

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

    <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>
    </style>

    <!-- ... -->

</resources>

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?

Answers


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>

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

Post Status

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

Search




Leave an answer