android - 按钮中图标和文本之间的距离

标签 android xml button

我在如下所示的 XML 中定义了一个按钮:

<Button
    android:layout_width="@dimen/logo_menu_width"
    android:layout_height="@dimen/logo_menu_height"
    android:layout_margin="@dimen/logo_menu_margins"
    android:gravity="left|center_vertical"
    android:background="@drawable/selector_blue"
    android:drawableStart="@drawable/ic_action_settings"
    android:paddingStart="6dp"
    android:text="Options"
    android:textColor="@color/blue_light"
    android:textSize="@dimen/logo_menu_text"
    android:id="@+id/buttonOptions"
    android:layout_gravity="center_horizontal" />

如何增加图标(通过 drawableStart 设置)和文本之间的距离?文本对齐设置为左对齐。 paddingStart 设置为 6dp,但它仅适用于图标,不适用于文本。

可以用XML文件设置吗?

我知道我可以使用包含 ImageView 和 TextView 的 LinearLayout 来做到这一点,但我试图限制 View 的嵌套。

最佳答案

使用 android:drawablePadding属性。

关于android - 按钮中图标和文本之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25232236/

相关文章:

c# - 如何在 C# 4.0 WPF webbrowser 应用程序上单击按钮或提交表单或单击 url 或单击图像

asp.net - asp :button and html's button的区别

android - mvc Controller 中重定向到 'market://details?id=my.package.name' 失败

android - FusedLocationProviderApi.KEY_LOCATION_CHANGED 已弃用。现在要做什么?

xml - R:如何获取站点时间的父属性和节点值?

Python正则表达式问题

java - 触摸事件后重绘 RecyclerView

java - getResponseCode 抛出 NPE

ios - NSXMLParserErrorMessage 内部错误 : Huge input lookup

html - 在不执行提交的表单中添加常规按钮