机器人:drawableLeft保证金和/或填充 [英] android:drawableLeft margin and/or padding

查看:129
本文介绍了机器人:drawableLeft保证金和/或填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置页边距或填充为我们添加了 Android上的图像:drawableLeft

Is it possible to set the margin or padding for the image which we added with the android:drawableLeft?

推荐答案

由于麦茎提到安卓drawablePadding ,只会迫使文本和绘制之间的填充,如果按钮足够小。

As cephus mentioned android:drawablePadding will only force padding between the text and the drawable if the button is small enough.

当铺设了更大的按钮,你可以使用安卓drawablePadding 连同安卓以下属性来安卓paddingRight 强制文字和向内可绘制对按钮的中心。通过分别调整左右填充可以使非常详细的调整的布局。

When laying out larger buttons you can use android:drawablePadding in conjunction with android:paddingLeft and android:paddingRight to force the text and drawable inward towards the center of the button. By adjusting the left and right padding separately you can make very detailed adjustments to the layout.

下面是一个使用填充,以推动文本和图标为例键间距小于他们将默认为:

Here's an example button that uses padding to push the text and icon closer together than they would be by default:

<Button android:text="@string/button_label" 
    android:id="@+id/buttonId"
    android:layout_width="160dip"
    android:layout_height="60dip"
    android:layout_gravity="center"
    android:textSize="13dip"
    android:drawableLeft="@drawable/button_icon"
    android:drawablePadding="2dip"
    android:paddingLeft="30dip"
    android:paddingRight="26dip"
    android:singleLine="true"
    android:gravity="center" />  

这篇关于机器人:drawableLeft保证金和/或填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆