【发布时间】:2020-12-24 16:17:23
【问题描述】:
如何消除图标后的间隙?我怎样才能正常环绕图标周围的按钮?
<Button
android:layout_marginStart="4dp"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/white"
app:icon="@drawable/googleg_standard_color_18"
app:iconTint="@null"/>
【问题讨论】:
-
您正在使用
Button。这是为带有可选可绘制对象的文本标题而设计的。如果您只想要图标,请使用ImageButton。 -
@CommonsWare 如果我用 imagebutton 替换,按钮会折叠成一个小矩形。看这里:i.imgur.com/qe4Egl9.png
-
这就是我不使用图片按钮的原因
-
您可以使用
android:src,而不是app:icon。见the documentation。 -
@CommonsWare 好的,现在尺寸很好,但我的自定义图标显示没有颜色。为什么?
标签: android xml android-button material-components-android