How to properly remove padding (or margin?) around buttons in Android?

前端 未结 13 989
醉梦人生
醉梦人生 2020-12-13 04:50

Currently, I have the following bottom log in button.

When button is not being pressed

When button is being pressed

The XML loo

13条回答
  •  执念已碎
    2020-12-13 05:30

    The best solution these days is just to use MaterialButton in place of Button.

    Note: MaterialButton is visually different from Button and AppCompatButton. One of the main differences is that AppCompatButton has a 4dp inset on the left and right sides, whereas MaterialButton does not. To add an inset to match AppCompatButton, set android:insetLeft and android:insetRight on the button to 4dp, or change the spacing on the button’s parent layout.

    When replacing buttons in your app with MaterialButton, you should inspect these changes for sizing and spacing differences.

    Source: https://material.io/develop/android/components/material-button/

提交回复
热议问题