How to make Images Larger (in height) in lazy list

2019-02-18 19:47发布

问题:

I m developing a book reader using the Lazy list project Here is Link

Problem: I m getting this look of Lazy List Small pages in height and blurred image which is very difficult to read.

I want this: It should look clear (not Blurred) and full page in height like this.

I know: Lazy list loads the sample size of bitmaps.

  • how can I get the images in full resolution which is about 600X921.

I tried this but not helpful main.xml

 <ListView
    android:id="@+id/list"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent" />

and this item.xml

<ImageView
    android:id="@+id/image"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="matrix"
    android:src="@drawable/stub" />

回答1:

I believe, the solution you are looking for, lies in this bit here (please do correct if I am wrong though):

//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;
}

This is from Line 99 to line 108 here: https://github.com/thest1/LazyList/blob/master/src/com/fedorvlasov/lazylist/ImageLoader.java. I am linking this so that you can check the code from the source and compare with your code.

You will need to change this bit here: final int REQUIRED_SIZE=70. Note that this number needs to the power of 2. With the default of 70, you will get small images and when used in applications which need to display bigger pictures, they will look distorted. Play around with that till you are satisfied with the result.

I personally use the value of final int REQUIRED_SIZE=512 without any problems whatsoever.

This should do the trick for you.