Open Image in full screen android

本小妞迷上赌 提交于 2019-12-06 08:49:25

问题


I have an image in thumbnail in my application and I want to display full screen image like it shows, when you click on any image in gallery and it displays in full screen.

How can i achieve that?


回答1:


You could launch the gallery app itself to view the image using below code snippet You could give this a try.

Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(file.getAbsolutePath()),"image/*");

startActivity(intent);




回答2:


I would suggest in 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 : "/sdcard/MyImages/image.png"

and than just show it in imageView of FullImage Activity like this :

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);
icon.setImageBitmap(ops);  // where icon is the imageView in your xml file


来源:https://stackoverflow.com/questions/8739285/open-image-in-full-screen-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!