我正在尝试将背景图像从 URL 设置为带位图的线性布局,但方法 BackgroundDrawable()
已被弃用,我找不到任何替代方法。
private LinearLayout linearLayout;
linearLayout = (LinearLayout) findViewById(R.id.layout);
Drawable drawableBitmap = new BitmapDrawable(getApplicationContext().getResources(), getBitmapFromURL(url));
linearLayout.setBackgroundDrawable(drawableBitmap);
最佳答案
试试这个解决方案。你的位图在这里,
LinearLayout bg = (LinearLayout) findViewById(R.id.linearlayout);
BitmapDrawable ob = new BitmapDrawable(getResources(), bitmap)
bg.setBackground(ob);
关于android - 来自 url 的 LinearLayout setBackgroundDrawable 位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44089318/