简体   繁体   English

图片预览-Android

[英]Image preview - Android

The image below is a cardview within a feedback section, the purpose is that the user picks an image from the device's gallery and attach it to an e-mail with that image being previewed, I got everything up and running (the user successfully picks an image and send it as an attachment). 下图是反馈部分中的cardview ,其目的是用户从设备的图片库中选择一张图片,并将其附加到电子邮件中,并预览该图片,从而使一切正常运行(用户成功选择了一个图片并作为附件发送)。 however I found myself stuck and can't figure how to add a preview to that image (in the grey part of the cardview which is an ImageView ) 但是我发现自己陷入困境,无法弄清楚如何向该图像添加预览(在cardview的灰色部分,即ImageView

PS. PS。 aside from the part where the user picks an image from the gallery and attaching it to the email I didn't make any progress in coding the preview part, and for preserving the community guidelines I found it useless to post unrelated code 除了用户从图库中选择图像并将其附加到电子邮件的部分之外,我在编码预览部分方面没有任何进展,并且为了保留社区准则,我发现张贴无关的代码毫无用处

卡片视图

Assuming you have the uri from the image taken by camera or gallery: 假设您从相机或图库拍摄的图像中获得了uri:

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
InputStream imageStream = context.getContentResolver().openInputStream(uri);
Bitmap bitmap = BitmapFactory.decodeStream(imageStream, null, options);
imageStream.close();

imageview.setImageBitmap(bitmap);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM