android - 全屏显示图像 - 失去质量安卓

标签 android bitmap android-imageview android-fullscreen

我正在尝试全屏显示图像,但图像质量似乎下降了。我从 URL 获取图像,下载它,当我显示图像时,它看起来很糟糕。我得到的图像是高分辨率的,所以我不知道问题出在哪里?

这是我显示图像的布局:

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/full_screen_banner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name" />

这是java代码:

imageViews.put(imageView, url);
Bitmap bitmap = memoryCache.get(url);
if (bitmap != null)
    imageView.setImageBitmap(bitmap);

最佳答案

如果您正在使用图像加载器,只需转到 imageloader 类即可

检查这些行

    private Bitmap decodeFile(File f) {
    try {
        // decode image size
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(new FileInputStream(f), null, o);
        // Find the correct scale value. It should be the power of 2.
        final int REQUIRED_SIZE = 100;
        int width_tmp = o.outWidth, height_tmp = o.outHeight;
        int scale = 1;
        while (true) {
            if (width_tmp / 2 < REQUIRED_SIZE
                    || height_tmp / 2 < REQUIRED_SIZE)
                break;
            width_tmp /= 2;
            height_tmp /= 2;
            scale *= 2;
        }
        // decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;
        return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
    } catch (FileNotFoundException e) {
    }
    return null;
}

关于android - 全屏显示图像 - 失去质量安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17849642/

相关文章:

java - 从 Android 位图对象生成 md5 和

android - 如何按比例缩放宽度等于 "match_parent"的任何图像( ImageView )?

java - Android编程,token "Invalid Character"语法错误,删除该token

java - 每 n 秒检索一次 Android 电池指标 [高效]

java - 转换为阿拉伯数字时出现 ArrayIndexOutOfBoundsException 中断

android - 如何拍照然后使用 TextRecognizer 读取其文本

android - 让付费的 Android 应用程序免费一周?

android - 如何使用 Picasso 或 Universal Android Loader 检索位图?

android - 无法使用 ontouchlistener 拖动自定义 ImageView

android - 如何在 Android 的 Imageview 上制作正弦波?