【发布时间】:2017-05-20 18:15:09
【问题描述】:
我正在尝试将背景图像从 URL 设置为带有位图的线性布局,但 BackgroundDrawable() 方法已被弃用,我找不到任何替代方法。
private LinearLayout linearLayout;
linearLayout = (LinearLayout) findViewById(R.id.layout);
Drawable drawableBitmap = new BitmapDrawable(getApplicationContext().getResources(), getBitmapFromURL(url));
linearLayout.setBackgroundDrawable(drawableBitmap);
【问题讨论】:
-
setBackgroundDrawable()在 API 级别 16 中已替换为setBackground(),如 the documentation 中所述。
标签: android image bitmap android-linearlayout deprecated