我正在尝试将多个图像按钮加载到ScrollView
中。这是我正在使用的代码,
Picasso.with(getContext()).load(url).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
BitmapDrawable bdrawable = new BitmapDrawable(bitmap);
btn.setBackground(bdrawable);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.topMargin = 0;
btn.setLayoutParams(params);
btn.setAdjustViewBounds(true);
btn.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
scrollLayout.addView(btn);
但图像未按预期加载。怎么回事?
感谢。