gpt4 book ai didi

android - Button.setCompoundDrawablesWithIntrinsicBounds() 的左/右填充?

转载 作者:IT老高 更新时间:2023-10-28 23:03:23 33 4
gpt4 key购买 nike

我正在尝试在按钮上设置左图标:

setCompoundDrawablesWithIntrinsicBounds(R.drawable.foo, 0, 0, 0);

但是图标被放置在我的按钮的左边缘和文本字符串上。有没有办法在提供的图标上指定一些左/右填充,使其不会正好靠在边缘?

谢谢

最佳答案

我相信您正在寻找的是 android:drawablePadding

这是一个使用 drawablePadding 以及 paddingLeftpaddingRight 在按钮中定位图像的示例

<Button
android:id="@+id/button"
android:layout_width="200dp"
android:layout_height="80dp"
android:drawableLeft="@drawable/ic_launcher"
android:drawablePadding="2dip"
android:paddingLeft="30dip"
android:paddingRight="26dip"
android:text="Test" />

Image example

关于android - Button.setCompoundDrawablesWithIntrinsicBounds() 的左/右填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10875750/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com