首页 > 解决方案 > 根据图像视图的大小滑动加载质量照片[如果尺寸小(图标)则低]

问题描述

我知道这种问题一直存在,但我遇到了一个具体问题..我正在使用 aglide library将我的图像路径转换sqlite databaseimageview我的expendablelistview..我正在使用photoview library它们来使它们可缩放..问题是大小imageviw 确定加载图像的质量..让我解释一下:

如果图像视图很大,则加载的图像很大并且在缩放中看起来不错。但是如果图像视图很小(比如说图标)......那么加载的质量很差,缩放时看起来真的很糟糕。

我想制作一个小的图像视图,但是单击时可以获得高质量的图像可缩放

这是我的代码:

case R.id.child3 :
    ImageView url = (ImageView) view;
    String urls;
    urls = cursor.getString(cursor.getColumnIndex(Database.DATABASE_CHILD_3));
    Glide.with(MainActivity.this).load(urls).into(url);
    url.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
            View mView = getLayoutInflater().inflate(R.layout.dialog_custom_layout, null);
            PhotoView photoView = mView.findViewById(R.id.imageView);
                photoView.setImageDrawable(((ImageView)view).getDrawable());
            mBuilder.setView(mView);
            AlertDialog mDialog = mBuilder.create();
            mDialog.show();
        }
    });
    break;

我的 list_child.xml

<ImageView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:id="@+id/child3"
    android:layout_centerHorizontal="true"

Dialog_custom_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        />
</LinearLayout>

标签: android

解决方案


通过添加 noTransformation 解决了它:

            Glide.with(MainActivity.this).load(urls).apply(noTransformation()).into(url);

public static RequestOptions noTransformation() {
        if (noTransformOptions == null) {
            noTransformOptions = new RequestOptions()
                    .dontTransform()
                    .autoClone();
        }
        return noTransformOptions;
    }

推荐阅读