我知道毕加索将图像加载到imageview等中,但是如何使用毕加索设置布局背景图像?
我的代码:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relativelayout);
relativeLayout.setBackgroundResource(R.drawable.table_background);
Picasso.with(MainActivity.this)
.load(R.drawable.table_background)
.resize(200, 200)
.into(relativeLayout);
return relativeLayout;
}
我在这里给出的任何错误都表明它无法解决。我有一个ScrollView和相对布局。
使用毕加索的回调
Picasso.with(getActivity()).load(R.drawable.table_background).into(new Target(){
@Override
public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
mainLayout.setBackground(new BitmapDrawable(context.getResources(), bitmap));
}
@Override
public void onBitmapFailed(final Drawable errorDrawable) {
Log.d("TAG", "FAILED");
}
@Override
public void onPrepareLoad(final Drawable placeHolderDrawable) {
Log.d("TAG", "Prepare Load");
}
})
更新:
也请检查此内容。如评论中提到的@OlivierH。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句