当前位置: 动力学知识库 > 问答 > 编程问答 >

android - How to make an image larger while clicking on it?

问题描述:

I wanted to know how to make an image larger or see an image full size when it's clicked.

I would like to have four small images on the screen so when the user click on one of the image it goes bigger so they can see the image properly.

I have searched to find out how to do this but haven't found anything.

If you could please help me I would appreciated.

Thank you :)

网友答案:

Check out the Hello Gallery tutorial, it'll help you understand thumbnails

http://developer.android.com/guide/tutorials/views/hello-gallery.html

网友答案:
check out this.................

onClick method of your thumbnail, you can start a new Activity in fullscreen mode: 

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

and pass the image uri or something which indicate the image source to the new activity :

Intent intent = new Intent(YouActivity.this, FullImage.class);
 intent.putExtra("imageUri", R.drawable.yourImage); // or the path to your image.

in FullImage Activity class

ImageView icon = (ImageView) findViewById(R.id.myImage);
 BitmapFactory.Options options = new BitmapFactory.Options(); 
options.inTempStorage = new byte[3*1024]; 

 Bitmap ops = BitmapFactory.decodeFile(path, options);
// instead path you can get an image from previous activity.

 icon.setImageBitmap(ops);
分享给朋友:
您可能感兴趣的文章:
随机阅读: