【问题标题】:TouchImageView zoom scaled to frame with Picasso使用毕加索缩放到框架的 TouchImageView 缩放
【发布时间】:2014-09-16 13:36:13
【问题描述】:

我使用 Universal Image Loader 库来加载一组图像和 TouchImageView 以允许缩放。我决定用毕加索替换 Universal Image Loader。一切正常,除了现在图像围绕一个比图像略大的框架缩放。

@Override
    public Object instantiateItem(ViewGroup view, int position) {
        View imageLayout = inflater.inflate(R.layout.item_pager_image, view, false);
        assert imageLayout != null;
        TouchImageView imageView = (TouchImageView) imageLayout.findViewById(R.id.image);
        final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
        spinner.setVisibility(View.INVISIBLE);
        Picasso.with(getApplicationContext()).setIndicatorsEnabled(false);
        Picasso.with(getApplicationContext()).load(images[position]).into(imageView,new Callback() {

            @Override
            public void onSuccess() {
                spinner.setVisibility(View.GONE);        
            }

            @Override
            public void onError() {

            }
        });
        view.addView(imageLayout, 0);
        return imageLayout;

为此,我已经花了几个小时的时间。这是 TouchImageView 对毕加索的一些问题吗?任何帮助都是不言而喻的。谢谢。

【问题讨论】:

  • 或者你可以做一件事.. imageView.setScaleType(ScaleType.Fit_XY)
  • 它的发生是因为图像视图缩放。缩放以适应 XY。它不会从框架中消失
  • @FunLove 感谢您的建议,但在我的情况下,执行 imageView.setScaleType(ScaleType.FIT_XY) 停止了缩放。
  • 我在使用这个库时遇到了类似的问题如果我没记错的话,但我现在使用 github.com/sephiroth74/ImageViewZoom 很长时间了,它与毕加索配合得很好。
  • @Yuraj 嘿,谢谢你的建议。你能告诉我如何实现这个库吗?我正在使用 eclipse,需要一个 jar 来实现它。

标签: android android-imageview picasso touchimageview


【解决方案1】:

Mahram Foadi 发布了 here 一个非常适合我的解决方案:

Picasso.with(context).load (someUri).into(new Target () {
   @Override
    public void onBitmapLoaded (final Bitmap bitmap,
        final Picasso.LoadedFrom loadedFrom) {
        someTouchImageView.setImageBitmap (bitmap);
    }

   @Override
    public void onBitmapFailed (final Drawable drawable) {
       Log.d(TAG, "Failed");
    }

   @Override
   public void onPrepareLoad (final Drawable drawable) {
        someTouchImageView.setImageDrawable (drawable);
   }
});

希望这有助于像我们这样的其他人将 TouchImageView 与 Picasso 一起使用;)

【解决方案2】:

当我将图像宽度和高度从 wrap_content 设置为 fill_parent 时,我发现整个问题以某种方式得到了解决。

【讨论】:

    【解决方案3】:

    如果您使用的是 Glide,这里是。 Glide 加载速度比 picasso 快,而且内存消耗更便宜

    Glide.with(context).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            someTouchImageView.setImageBitmap(resource);
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多