【发布时间】:2013-07-11 06:45:24
【问题描述】:
我想通过编程方式在中心位置的按钮上设置图标,如上图,请任何人帮助我...
【问题讨论】:
-
Button 类的文档是怎么说的?
-
我不知道我是一个新的机器人
-
如果您不知道答案,谁会阻止我的问题,请阅读并走开......
我想通过编程方式在中心位置的按钮上设置图标,如上图,请任何人帮助我...
【问题讨论】:
愿这对你有帮助..
为 Drawable 文件夹中的按钮设置背景图像,然后使用以下代码:
btn.setBackgroundResource(R.drawable.image);
或
btn.setBackgroundDrawable(getResources().getDrawable(R.drawable.image));
或使用: setCompoundDrawableWithIntrinsicBounds().
在其文档中查看更多关于 setCompoundDrawableWithIntrinsicBounds() 的信息:CLICK HERE
编辑:
试试这个方法: setCompoundDrawableWithIntrinsicBounds(R.drawables.minus,0,0,0);
在 XML 中添加这一行:android:paddingLeft="100dp"
【讨论】:
setCompoundDrawableWithIntrinsicBounds()的文档会帮助你..