ImageView Android 内存
我原来的问题的后续内容。
有没有一种方法可以在 Android 应用程序中使用 ImageViews 而不使用大量 RAM?
在原来的 问题 中,我发现我的应用程序使用了大量 RAM,并发现它是我也使用了所有 RAM 的 ImageView。
为了获取我使用的图像,
public void addPictureOnClick(View view){
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
// currImageURI is the global variable I'm using to hold the content:// URI of the image
Uri currImageURI = data.getData();
image.setImageURI(currImageURI);
}
我想知道是否有其他方法来显示图片而不是 URI?
A followup from my original question.
Is there a way to use ImageViews in android apps without using a lot of RAM?
In the original question I found that my app used a lot of RAM, and found that it was the ImageViews which I used that too up all the RAM.
To get the Image I use
public void addPictureOnClick(View view){
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
// currImageURI is the global variable I'm using to hold the content:// URI of the image
Uri currImageURI = data.getData();
image.setImageURI(currImageURI);
}
I would like to know if there is another way to show pictures rather than the URI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以缩放图片:
如果图像较大,缩放过程可能会更长,但显示时的内存负载会较低。
编辑:inSampleSize 值增加得越多,花费的时间就越多,内存使用量就越少。
http://developer.android.com/reference/android/graphics /BitmapFactory.Options.html#inSampleSize
You can scale your pictures :
The scaling process could be longer if you have big images, but the memory load will be lower on display.
Edit: More you increase the inSampleSize value, more times it take, less memory usage you will have.
http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inSampleSize