1

アクティビティに4つの画像ビューがあり、ユーザーがいずれかの画像をクリックした場合、画像が飛び出して全画面表示されるようにしたいのですが、どうすればこれを実現できますか?

Webビューを使用する方が良いオプションですか?

コード:パッケージcom.integrated.mpr;

import java.io.File;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ImageView;
import android.widget.TextView;

public class FinalShow extends Activity{



    ImageView iva;
    ImageView ivb;
    ImageView ivc;
    ImageView ivd;

    File folder = null;


    Model model = new Model();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.finalshow);



        iva = (ImageView) findViewById(R.id.iva);
        ivb = (ImageView) findViewById(R.id.ivb);
        ivc = (ImageView) findViewById(R.id.ivc);
        ivd = (ImageView) findViewById(R.id.ivd);



        String sdcardstate = android.os.Environment.getExternalStorageState();

        if(sdcardstate.contentEquals(android.os.Environment.MEDIA_MOUNTED)){

            String filepath = Environment.getExternalStorageDirectory().getPath();
            folder = new File(filepath,model.s);//model.s contains the name of folder

            File fa = new File(folder,"bmp1.png");
            Bitmap bmpa = BitmapFactory.decodeFile(fa.getAbsolutePath());
            iva.setImageBitmap(bmpa);

            File fb = new File(folder,"bmp2.png");
            Bitmap bmpb = BitmapFactory.decodeFile(fb.getAbsolutePath());
            ivb.setImageBitmap(bmpb);


            File fc = new File(folder,"bmp3.png");
            Bitmap bmpc = BitmapFactory.decodeFile(fc.getAbsolutePath());
            ivc.setImageBitmap(bmpc);


            File fd = new File(folder,"bmp4.png");
            Bitmap bmpd = BitmapFactory.decodeFile(fd.getAbsolutePath());
            ivd.setImageBitmap(bmpd);

        }


    }



}
4

2 に答える 2

5

最初は見えない1つのimageview(親の完全な高さと幅を指定)を作成します。任意の画像をクリックしたら、その画像をこの新しい画像ビューに設定して表示します。

まず、新しく追加されたimageviewが完全な高さと幅をカバーしていることを確認します。より良いのは、相対レイアウトを使用することです

<?xml version="1.0" encoding="utf-8"?>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="14dp"
    android:src="@drawable/ic_launcher" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/imageView1"
    android:src="@drawable/ic_launcher" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageView1"
    android:layout_below="@+id/imageView1"
    android:layout_marginTop="19dp"
    android:src="@drawable/ic_launcher" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/imageView2"
    android:layout_alignTop="@+id/imageView3"
    android:src="@drawable/ic_launcher" />

<ImageView android:id="@+id/fullview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/ic_launcher"
    android:visibility="gone"/>

Javaコードでは、

      firstImageView.setOnclickListener(new ClickListener());
      secondImageView.setOnclickListener(new ClickListener());
      thirdImageView.setOnclickListener(new ClickListener());
      fourthImageView.setOnclickListener(new ClickListener());



 class ClickListener implements OnClickListener {

    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch(v.getId()) {
                     case R.id.firstimage: // set image to fullimageview; break;
                      case R.id.secondimage:// set this image to fullimage break;
                    }

    }

}
于 2012-05-29T04:40:22.763 に答える
0

新しいアクティビティを作成することを1つ実行します。その後、[画像]をクリックして、間に別のアクティビティを呼び出し、ポップアップ用のアニメーションを追加できます。

新しいアクティビティでは、あなたが言ったように画像を表示します:画像の値を渡すために、共有設定またはインテントを使用することもできます:幸運

于 2012-05-29T04:40:41.900 に答える