【发布时间】:2015-12-03 22:10:45
【问题描述】:
我有一个RecyclerView 和LinearLayoutManager。我想有一张图片作为背景,但图片大小是动态的。我希望它是全宽并具有相应的高度。这是我目前拥有的:
我试过这个:
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吗?
标签: android height android-recyclerview picasso