【问题标题】:setbackgrounddrawable dont works in android API 23setbackgrounddrawable 在 android API 23 中不起作用
【发布时间】:2020-02-04 18:51:03
【问题描述】:

此代码在 API > 23 中有效,但在 API 23 中无效。 我需要 ImageButton 的 setBackground 一个可绘制图像。

我该如何解决这个问题?


    ImageButton imgbt = findViewById(R.id.imgbt );

    imgbt .setBackgroundDrawable(new BitmapDrawable(EstadoDescritivo.this.getResources(), BitmapFactory.decodeResource(getResources(),
                                    R.drawable.ic_car)));

谢谢

【问题讨论】:

标签: java android android-studio android-layout


【解决方案1】:

你可以试试这个:

而不是使用setBackgroundDrawable

imgbt.setBackgroundResource(R.drawable.ic_car);

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2016-09-04
    • 2020-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-14
    • 2018-07-17
    • 2014-02-22
    相关资源
    最近更新 更多