2
我有RecyclerView
与LinearLayoutManager
。我想要一张图片作为背景,但图片大小是动态的。我希望它是全宽,并有相应的高度。这是我目前有:加载图像后更新RecyclerView项目的高度?
我尝试这样做:
Picasso.with(context).load(pictureUrl).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom)
{
holder.picture.setImageBitmap(bitmap);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) holder.itemView.getLayoutParams();
params.height = bitmap.getHeight();
holder.itemView.setLayoutParams(params);
//notifyItemChanged(position);
}
@Override public void onBitmapFailed(Drawable drawable) {}
@Override public void onPrepareLoad(Drawable drawable) {}
});
但后来它甚至不加载所有:
编辑:似乎,onBitmapLoaded()
甚至没有被调用,虽然onPrepareLoad()
确实得到。
你试过adjustViewBounds了吗? –