android - 根据图像视图的大小滑动加载质量照片[如果尺寸小(图标)则低]
问题描述
我知道这种问题一直存在,但我遇到了一个具体问题..我正在使用 aglide library
将我的图像路径转换sqlite database
为imageview
我的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>
解决方案
通过添加 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;
}
推荐阅读
- python - 列表中两个元素之间每个元素的时间增量
- c++ - 如何在 CPP 中命名选项卡/列?
- python-3.x - AttributeError:“屏幕”对象在 Python KivyMD 中没有属性“文本”
- generics - 在 .NET Core 中的特定通用服务上定义注入服务
- oracle - 我可以在 Oracle 中删除整个表而不撤消吗?
- c# - 为什么 blazor 会渲染两次?
- apache-superset - Apache Superset 最新版本介于 0.38.1 和 1.0.1 之间
- javascript - 当我尝试从 chrome 扩展中的 url 下载文件时,Chrome 崩溃
- c++ - 这种执行重新排序是否可能
- ruby-on-rails - 某些 pdf 页面中缺少页眉和页脚 wicked_pdf