【问题标题】:Android Button Vertical Padding?Android按钮垂直填充?
【发布时间】:2021-06-06 13:33:46
【问题描述】:

这是我的代码:

<com.google.android.material.button.MaterialButton
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:text="nice"
            android:paddingVertical="0dp"
            android:textColor="@color/light_grey"
            app:strokeWidth="2dp"
            app:strokeColor="@color/light_grey"
            app:cornerRadius="10dp"
            android:backgroundTint="@color/white"/>

这就是按钮。

Image of the button 它有一个垂直空间,显然不是填充,使按钮小于 40dp。我不想通过增加按钮的高度来解决这个问题。

【问题讨论】:

  • 你可能想试试 marginTop 或 paddingTop 属性

标签: android button padding


【解决方案1】:

您可以设置Insets 属性,因此在您的按钮中添加:

android:insetTop="0dp"
android:insetBottom="0dp"

如果你需要,还有insetLeftinsetRight

【讨论】:

  • 简单的答案,正是我所需要的。谢谢!
猜你喜欢
  • 2016-04-29
  • 1970-01-01
  • 2019-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-23
  • 2020-08-11
  • 1970-01-01
相关资源
最近更新 更多