单击按钮后,我试图在按钮的右侧设置图像.我想通过代码来做到这一点.
我已经看到如何通过代码更改后台资源,但我无法找到任何显示如何通过代码更改侧面的示例.可能吗?
eye*_*yus 28
你需要使用
public void setCompoundDrawables (Drawable left, Drawable top, Drawable right,
Drawable bottom)
Run Code Online (Sandbox Code Playgroud)
对于任何不需要的方法,使用null的方法.
小智 8
通常您可以使用此更改
Drawable draw = getResources().getDrawable(R.drawable.facebook);
myButton.setCompoundDrawablesWithIntrinsicBounds(null, null, draw, null);
Run Code Online (Sandbox Code Playgroud)
请注意,您可能会错过按钮文字.
| 归档时间: |
|
| 查看次数: |
12196 次 |
| 最近记录: |