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中显示。您也可以使用此选项。