我有一个垂直的LinearLayout,其中一个项目是ImageView使用Picasso加载的.我需要将图像的宽度提升到整个设备宽度,并显示图像的中心部分被固定高度(150dp)裁剪.我目前有以下代码:
Picasso.with(getActivity())
.load(imageUrl)
.placeholder(R.drawable.placeholder)
.error(R.drawable.error)
.resize(screenWidth, imageHeight)
.centerInside()
.into(imageView);
Run Code Online (Sandbox Code Playgroud)
我应该把哪个值成screenWidth和imageHeight(= 150dp)?
在我的功能:
public void getPointMarkerFromUrl(final String url, final OnBitmapDescriptorRetrievedListener listener) {
final int maxSize = context.getResources().getDimensionPixelSize(R.dimen.icon_max_size);
Target t = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
if (bitmap != null)
listener.bitmapRetrieved(getBitmapDescriptorInCache(url, bitmap));
else
loadDefaultMarker(listener);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
loadDefaultMarker(listener);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};
Picasso.with(context)
.load(url)
.resize(maxSize, maxSize)
.into(t);
}
Run Code Online (Sandbox Code Playgroud)
我第一次加载图片时从不调用onBitmapLoaded().我已经阅读了一些话题,如https://github.com/square/picasso/issues/39,建议使用fetch(Target t)方法(这似乎是弱引用的问题......),但是这个函数在毕加索的最后一个版本(2.3.2)中没有.我只有一个fetch()方法,但我不能同时使用(mytarget)
你能解释一下如何使用fetch()和自定义Target吗?谢谢.
文件:http://square.github.io/picasso/javadoc/com/squareup/picasso/RequestCreator.html#fetch--
我正在使用Picasso在我的Android应用程序中显示图像:
/**
* load image.This is within a activity so this context is activity
*/
public void loadImage (){
Picasso picasso = Picasso.with(this);
picasso.setDebugging(true);
picasso.load(quiz.getImageUrl()).into(quizImage);
}
Run Code Online (Sandbox Code Playgroud)
我已启用调试,它始终显示红色和绿色.但从不显示黄色
现在,如果我下次加载相同的图像并且互联网不可用,则不会加载图像.
问题:
我正在尝试使用picasso库来加载url到imageView,但我无法context正确使用picasso库.
public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
private List<Post> mDataset;
// Provide a reference to the views for each data item
// Complex data items may need more than one view per item, and
// you provide access to all the views for a data item in a view holder
public class ViewHolder extends RecyclerView.ViewHolder {
// each data item is just a string in this case
public TextView txtHeader;
public ImageView pub_image;
public ViewHolder(View v) {
super(v); …Run Code Online (Sandbox Code Playgroud) 我有以下代码在Picasso中加载图像,使用drawable在占用图像下载时显示占位符.我想要的是一个动画旋转进度条样式微调器,在图像加载时围绕和周围动画,就像我在大多数专业应用程序中看到的那样.毕加索似乎不支持这一点,只有静态图像可绘制.有没有办法让它与毕加索合作,还是我必须做一些与众不同的事情?
Picasso.with(context).load(url)
.placeholder(R.drawable.loading)
.error(R.drawable.image_download_error)
.into(view);
Run Code Online (Sandbox Code Playgroud) 问题已被提出,并且我正在使用的毕加索版本有一个承诺:如何使用Picasso将圆形位图发送到ImageView?我是毕加索的新手,我唯一使用的是
Picasso.with(context).load(url).resize(w, h).into(imageview);
Run Code Online (Sandbox Code Playgroud)
我已经找到https://gist.github.com/julianshen/5829333但我不知道如何以非尴尬的方式将它与上面的行结合起来.
我正在寻找Android中的异步图像加载和缓存库.我打算使用Picasso,但我发现Universal Image Loader在GitHub上更受欢迎.有谁知道这两个图书馆?优点和缺点的摘要会很棒.
(我的所有图像都在本地磁盘上,因此我不需要联网,因此我认为Volley不合适)
有没有办法在使用建筑师时听毕加索的事件,如:
Picasso.with(getContext()).load(url).into(imageView);
我想打电话requestLayout()和invalidate()父GridView所以它会适当调整,但我不知道如何设置监听器或回调.
我看到Picasso有错误事件报告,但有成功事件吗?
我正在使用Picasso为我的应用下载图像.
我遇到的情况是我需要Bitmap在加载到第一个之前访问第一个ImageView.Downloader.Response该类的存在似乎表明这是可能的,但我找不到任何使用示例.我不想写一堆更多的代码来异步处理这个特殊情况,如果它可以与Picasso一起使用的话.
谁能告诉我怎么做?