setCompundDrawables()在android M中不起作用

时间:2016-02-22 06:38:05

标签: android android-drawable android-button compound-drawables

这是我用来调整drawable大小的代码:

Drawable drawable = model_btn.getCompoundDrawables()[0];


        drawable.setBounds(0, 0, (int) (height * 0.065),
                (int) (height * 0.065));


        ScaleDrawable sd = new ScaleDrawable(drawable, 0, 50, 50);

如果我使用

model_btn.setCompoundDrawables(sd.getDrawable(), null, null, null);

左侧没有画布。

如果我使用:

  model_btn.setCompoundDrawablesWithIntrinsicBounds(sd.getDrawable(), null, null, null);

它显示左侧可绘制但没有调整大小。

您的建议表示赞赏。

1 个答案:

答案 0 :(得分:0)

你可以试试这个

model_btn.setCompoundDrawablesWithIntrinsicBounds( R.drawable.id, 0, 0, 0);