我正在使用惰性列表项目开发图书阅读器 Here is Link
问题:我看到了 Lazy List 的外观 高度小的页面和模糊的图像非常难以阅读。
我想要这个: 它应该像这样看起来清晰(不是模糊)和整页高度。
我知道: 惰性列表加载位图的样本大小。
- 如何获得大约 600X921 的全分辨率图像。
我试过了,但没用 main.xml
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
和这个item.xml
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="matrix"
android:src="@drawable/stub" />
最佳答案
我相信,您正在寻找的解决方案就在这里(如果我错了请更正):
//Find the correct scale value. It should be the power of 2.
final int REQUIRED_SIZE=70;
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;
}
这是从第 99 行到第 108 行:https://github.com/thest1/LazyList/blob/master/src/com/fedorvlasov/lazylist/ImageLoader.java .我正在链接它,以便您可以检查源代码并与您的代码进行比较。
您需要在此处更改此位:final int REQUIRED_SIZE=
70。请注意,此数字需要 2 的幂。使用默认值 70,您将获得小图像,当用于需要显示较大图片的应用程序时,它们看起来会变形。试一试,直到您对结果满意为止。
我个人使用 final int REQUIRED_SIZE=512
的值没有任何问题。
这应该可以解决问题。
关于android - 如何在惰性列表中使图像更大(高度),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14621367/