5

ImagePagerActivityのユニバーサルイメージローダーでImageViewZoomを使用したいと思います。

だから、私がしたこと:

  1. プロジェクトのクラスパスにimageviewtouch.jarを追加しました。
  2. ImagePagerActivityで、instantiateItem()関数の1行を変更しました。ImageViewの行にコメントを付け、ImageViewTouchに置き換えました(4.および5.行)

    @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;
    }
    
  3. /res/layout/item_pager_image.xmlで、 ImageViewit.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に変更すると、すべて問題ありませんが、もちろんズーム機能はありません。誰かが私が間違っていることを知っているなら、私は非常に感謝するでしょう。(英語でごめんなさい)

4

1 に答える 1

0

ImageViewTouchパラメータandroid:layout_height="0dp"を他の値に変更します。

于 2012-11-14T07:39:52.230 に答える