使用位图分配relativeLayout背景的任何想法?
RelativeLayout bg = (RelativeLayout) findViewById(R.id.relativeLayout);
bg.setBackgroundDrawable();// deprecated
答案 0 :(得分:2)
改为使用setBackground()
。
RelativeLayout bg = (RelativeLayout) findViewById(R.id.relativeLayout);
bg.setBackground(drawable);
答案 1 :(得分:1)
RelativeLayout bg =(RelativeLayout)findViewById(R.id.relativeLayout);
1) bg.setBackgroudDrawable(Drawable); 2) bg.setBackgroundResource(int);
答案 2 :(得分:0)
RelativeLayout bg = (RelativeLayout) findViewById(R.id.relativeLayout);
Drawable d = new BitmapDrawable(bm);
bg.setBackgroundDrawable(d);
BitmapDrawable()已被弃用,我仍然无法将位图设置为relativeLayout的backgorund
答案 3 :(得分:0)
使用
bitmap //Your bitmap Image
RelativeLayout bg = (RelativeLayout) findViewById(R.id.relativeLayout);
BitmapDrawable ob = new BitmapDrawable(getResources(), bitmap)
bg.setBackground(ob);