How to remove padding around buttons in Android?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When an Android button looks like it has too much empty space around the label, the cause is not always plain padding. It may be actual padding, background insets from the drawable, minimum size rules, or Material component insets.
That is why android:padding="0dp" sometimes appears to do nothing. The correct fix depends on which layer is creating the extra space.
Start With Real Padding
For a standard Button, the first thing to try is explicit zero padding:
If only one side matters, set the individual edges:
This removes content padding inside the view, but it does not remove every other source of spacing.
Programmatic Adjustment
If the padding must change at runtime, set it in code:
This is useful when different screen states need different spacing, but it still only affects the view's actual padding values.
Material Buttons Often Have Insets Too
If you are using MaterialButton, extra space can come from insets defined by the Material component style. In that case, clearing padding alone may not fully flatten the visual spacing.
A common XML adjustment is:
Those inset attributes are often the missing piece when the button still looks padded after zeroing standard padding.
Check Minimum Size Constraints
Buttons can also appear to have padding because they enforce a minimum width or height. If the goal is a very compact button, check attributes such as:
For AppCompat widgets, you may also need:
The exact fix depends on the widget type and style, but the main lesson is that visual spacing is not always padding.
Background Drawables Can Add Optical Space
Even when padding and insets are zero, the button background itself may contain visual margins or rounded shapes that make the content look farther from the edge. If the built-in background fights your layout, use or create a simpler background drawable instead of trying to solve everything with padding values.
This is especially common when customizing buttons for icon-only or compact-chip-like designs.
Accessibility Still Matters
Removing internal spacing aggressively can make a button look tighter, but it can also hurt usability. A visually compact button still needs a practical touch target. On Android, a design that removes every bit of apparent padding can become hard to tap even if it looks precise on screen.
So the right question is not only "how do I remove the space" but also "should this control still remain easy to use."
Common Pitfalls
The most common mistake is setting android:padding="0dp" and assuming that must remove all visual spacing. Material insets, minimum size, and background shape can all keep the button looking padded.
Another common issue is shrinking the visual content so much that the touch target becomes poor. Compact UI is not automatically good UI.
Developers also sometimes adjust one XML attribute while the real problem lives in the applied theme or component style. If the layout change seems ignored, inspect the widget type and style before assuming Android is broken.
Finally, be careful when mixing Button, AppCompatButton, and MaterialButton. Their defaults are similar but not identical.
Summary
- Start by setting button padding to zero when the extra space is true content padding.
- For
MaterialButton, also inspect and clear inset attributes when needed. - Check minimum width, minimum height, and background styling if the button still looks padded.
- Visual spacing is not always caused by the
paddingproperty alone. - Keep touch-target usability in mind before removing too much space from a button.

