【问题标题】:Cant set the Linear layout background from a path无法从路径设置线性布局背景
【发布时间】:2014-12-08 14:53:00
【问题描述】:

我的代码是这样的

 ll.setBackground(Drawable.createFromPath(new ImageLoader().fullPath+"/desiredFilename.png"));

ll是我的线性布局的对象,这是正确的方法吗

   Bitmap bitmap = BitmapFactory.decodeFile(new ImageLoader().fullPath+"/desiredFilename.png");
		            Resources res=getResources();
		            BitmapDrawable bitmapDrawable = new BitmapDrawable(res,bitmap);
		            ll.setBackground(bitmapDrawable);

我也使用了这个代码,但是没用 显示错误 noSuchMethods

【问题讨论】:

标签: android android-layout android-activity


【解决方案1】:

试试这个方法

  ll.setBackgroundDrawable(bitmapDrawable);

而不是

  ll.setBackground(bitmapDrawable);

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2011-11-30
  • 1970-01-01
  • 1970-01-01
  • 2016-01-26
  • 1970-01-01
  • 2017-07-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多