Remove space between bounds and button border

南笙酒味 提交于 2020-03-16 06:42:28

问题


How do I remove those space between Button border and view bounds tried setting padding to 0dp but with no results.
These is material button with default style.


回答1:


The MaterialButton has a default style with these insets:

 <style name="Widget.MaterialComponents.Button"..>
    <item name="android:insetLeft">0dp</item>
    <item name="android:insetRight">0dp</item>
    <item name="android:insetTop">@dimen/mtrl_btn_inset</item>
    <item name="android:insetBottom">@dimen/mtrl_btn_inset</item>
    ...
 </style>

The value of @dimen/mtrl_btn_inset is 6dp.

Just use:

  <com.google.android.material.button.MaterialButton
      android:insetTop="0dp"
      android:insetBottom="0dp"
      ../>




回答2:


you can use weight and make the width 0dp then space will be removed.



来源:https://stackoverflow.com/questions/58351936/remove-space-between-bounds-and-button-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!