サイズを変更する必要がある4つの画像を持つviewPagerがあります。さまざまなオプションを実装しましたが、オプションは実行されません。私はさまざまなオプションを書きます:
getView に次のように入力します。
image.setImageBitmap(bitmap);
ビットマップは以下を取得します。
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(bitmapOriginal, null, options); int sampleSize = 1; while ((options.outHeight > 600 * sampleSize) &&(options.outWidth > 400 * sampleSize)) { sampleSize *= 2; } options.inJustDecodeBounds = false; options.inMutable = false; options.inSampleSize = sampleSize; Bitmap bm=BitmapFactory.decodeStream(bimapOriginal, null, options);
しかし、それは非常にゆっくりです。
最後のコードを AsyncTask() に入れましたが、すばやくスクロールできません。
私は
onPageScrollStateChange(int state)
状態のときだけ画像を表示しています
SCROLL_STATE_IDLE
が、効果は他の場合と同じです。私は LruCache を使用し、画像を Asynctask の LruCache に保存します。
私が入れたinstantiateItemにfor(int i=position *4;i<(position +1)*4 +4;i++) { //NameImage is an Array with the name of image. Every time that calling instantiateItem save 4 images in LruCache new BitmapWorkerTask(nameImage[i).executorOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null);
しかし、問題は前のケースと同じで、すばやくスクロールできず、アプリが非常に遅いです。
大きな品質とサイズの画像があります。viewPagerですばやくスクロールするにはどうすればよいですか?