android - ImageView 加载高分辨率图像质量很差

标签 android android-studio android-imageview android-listfragment universal-image-loader

我正在使用 ListFragment 来显示延迟加载的 ImageView 对象的 ListView,使用 Android Universal Image Loader .正确的数据来 self 的数据源,我有我相当高分辨率的图像(大约 1000 像素宽,150kb)的 URL。我正在使用它们来完全填充 110dp 高的每一行。

我遇到的问题是图像以非常差的分辨率加载:

enter image description here

问题不在于源图像,因为它的质量足够高:

http://www.puc.edu/__data/assets/image/0006/127581/IMG_5155.jpg

我将图像居中然后裁剪它:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="110dp">

    <TextView
        android:id="@+id/galleryTitle"
        android:layout_width="wrap_content"
        android:layout_height="80dp"
        android:layout_marginLeft="95dp"
        android:layout_marginRight="5dp"
        android:gravity="center_vertical"
        android:hint="16dp"
        android:lineSpacingExtra="0dp"
        android:lines="3"
        android:text="TextView"
        android:textSize="16sp"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/galleryImageView"
        android:layout_width="fill_parent"
        android:layout_height="110dp"
        android:scaleType="centerCrop"
        android:src="@drawable/default_background" />

</RelativeLayout>

在行中显示图像:

public View getView(int position, View convertView, ViewGroup parent) {

        View itemView;
        TextView title;

        // Get the news item object
        PUCObjects.PUCPhotoGalleryItem item = items.get(position);

        // Inflater Service
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        itemView = inflater.inflate(R.layout.photos_gallery_row, parent, false);
        title = (TextView) itemView.findViewById(R.id.galleryTitle);
        ImageView imageView = (ImageView) itemView.findViewById(R.id.galleryImageView);

        // Set the Image
        imageLoader.DisplayImage(item.imageUrlExtraLarge, imageView);

        // Set the text
        title.setText(item.title);

        return itemView;
    }

为什么它显示分辨率如此低的图像有什么想法吗?

最佳答案

图片似乎缩小了比例。查看该库,默认功能是 2 次图像采样的幂。我认为这是您问题的根源。

例如:

DisplayImageOptions opts = new DisplayImageOptions.Builder().imageScaleType(ImageScaleType.NONE).build();

imageLoader.DisplayImage(item.imageUrlExtraLarge, imageView, opts);

关于android - ImageView 加载高分辨率图像质量很差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25071007/

相关文章:

Android 支持库设置错误

android - 从 ParseQueryAdapter 返回项目数

android - Flutter 未在 Android Studio 中显示调色板的 intellij 建议框

android - 为什么我的动画不正确并且图像加载在某些图像中花费更多时间?

android - android中 ImageView 的图像重叠

Android:使用 AlertDialog 的偏好

android - 找不到类,使用 Android Studio 3.0.1、Room、Kotlin 的 androidTest 中的空测试套件

android - Android Studio 中的项目不再起作用

java - 我可以使用什么代替 setImageResource() 来处理低于 16 的 API?

android - 如何为 Android 创建一个充满按钮的表格