【问题标题】:setCompundDrawables() not working in android MsetCompundDrawables() 在 android M 中不起作用
【发布时间】:2016-06-03 12:01:16
【问题描述】:

这是我用来调整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);

drawable left 没有显示出来。

如果我使用:

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

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

感谢您的建议。

【问题讨论】:

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


    【解决方案1】:

    你可以试试这个

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    • 2016-05-05
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 2017-07-17
    相关资源
    最近更新 更多