本文介绍了影像未ImageViewZoom显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想使用 ImageViewZoom ,提供的的在ImagePagerActivity。

I'd like to use ImageViewZoom with Universal Image Loader in ImagePagerActivity.

所以,我做了什么:

  1. 在我加入imageviewtouch.jar到项目类路径中。
  2. 在ImagePagerActivity我instantiateItem改变一行()函数。我评论线哪里是ImageView的,取而代之它ImageViewTouch(4和5号线)

  1. I added imageviewtouch.jar to project classpath.
  2. In ImagePagerActivity I changed one line in instantiateItem() function. I commented line where is ImageView and replaced it to ImageViewTouch (4. and 5. line)

@Override
public Object instantiateItem(View view, int position) {
    final View imageLayout = inflater.inflate(R.layout.item_pager_image, null);
    //final ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
    final ImageViewTouch imageView = (ImageViewTouch) imageLayout.findViewById(R.id.image);

    final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
    final TextView textView = (TextView)imageLayout.findViewById(R.id.text);

    imageLoader.displayImage(images[position], imageView, options, new ImageLoadingListener() {


        public void onLoadingStarted() {
            spinner.setVisibility(View.VISIBLE);
        }


        public void onLoadingFailed(FailReason failReason) {
            String message = null;
            switch (failReason) {
                case IO_ERROR:
                    message = "Input/Output error";
                    break;
                case OUT_OF_MEMORY:
                    message = "Out Of Memory error";
                    break;
                case UNKNOWN:
                    message = "Unknown error";
                    break;
            }
            Toast.makeText(ImagePagerActivity.this, message, Toast.LENGTH_SHORT).show();

            spinner.setVisibility(View.GONE);
            imageView.setImageResource(android.R.drawable.ic_delete);
        }


        public void onLoadingComplete(Bitmap loadedImage) {
            spinner.setVisibility(View.GONE);
            Animation anim = AnimationUtils.loadAnimation(ImagePagerActivity.this, R.anim.fade_in);
            imageView.setAnimation(anim);
            anim.start();
        }


        public void onLoadingCancelled() {
            // Do nothing
        }
    });

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

  • 在/res/layout/item_pager_image.xml我更换的ImageView it.sephiroth.android.library.imagezoom.ImageViewTouch

     <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="1dip" >
    
      <it.sephiroth.android.library.imagezoom.ImageViewTouch
         android:layout_weight="1"
         android:id="@+id/image"
         android:layout_width="match_parent"
         android:layout_height="0dp"
         android:scaleType="fitCenter" />
    
      <ProgressBar
        android:id="@+id/loading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="gone" />
    
    </FrameLayout>
    

  • 我运行这个Android应用程序,但是当我选择图片寻呼机在菜单屏幕上,没有显示,只有黑色的屏幕图像。在logcat中我看到,图像下载并显示...如果我改变ImageViewTouch原始的ImageView,一切都OK了,当然也没有变焦功能。如果有人知道我做错了,我会非常感激。 (对不起,我英文)

    I run this Android application, but when I choose Image Pager in menu screen, there is no image displayed, only black screen. In logcat I see that image was downloaded and displayed... If I change ImageViewTouch to original ImageView, everything is OK, but of course there is no zoom feature. If someone knows what I do wrong, I'd be very grateful. (sorry for my English)

    推荐答案

    更改ImageViewTouch参数的android:layout_height =0dp其他值

    这篇关于影像未ImageViewZoom显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    1403页,肝出来的..

    09-08 21:57