Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓:让图像在触摸屏上全屏显示_Android_Zooming - Fatal编程技术网

Android 安卓:让图像在触摸屏上全屏显示

Android 安卓:让图像在触摸屏上全屏显示,android,zooming,Android,Zooming,在我的应用程序中,我在文本之间显示了许多图像 我想让图像在触摸屏上放大到全屏。我不知道怎么做。我也搜索了很多 提前感谢…将位图转换为字节数组 Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.P

在我的应用程序中,我在文本之间显示了许多图像

我想让图像在触摸屏上放大到全屏。我不知道怎么做。我也搜索了很多


提前感谢…

将位图转换为字节数组

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
使用intent将其传递给下一个活动

Intent intent = new Intent(this, NextActivity.class);
intent.putExtra("picture", byteArray);
startActivity(intent);
从Bundle中获取字节数组并转换为位图图像:-

Bundle extras = getIntent().getExtras();
byte[] byteArray = extras.getByteArray("picture");

Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
ImageView image = (ImageView) findViewById(R.id.imageView1);

image.setImageBitmap(bmp);

只需确保
ImageView
的宽度和高度与
match\u parent

的宽度和高度相同即可。您想缩进以进行缩放吗?尝试此操作,将该图像传递给新活动,并在高度和宽度与match\u parent相同的ImageView中显示。您也可以使用此选项。