2013-08-30 26 views

回答

-1
Bitmap getPreview(URI uri) { 
    File image = new File(uri); 

    BitmapFactory.Options bounds = new BitmapFactory.Options(); 
    bounds.inJustDecodeBounds = true; 
    BitmapFactory.decodeFile(image.getPath(), bounds); 
    if ((bounds.outWidth == -1) || (bounds.outHeight == -1)) 
     return null; 

    int originalSize = (bounds.outHeight > bounds.outWidth) ? bounds.outHeight 
      : bounds.outWidth; 

    BitmapFactory.Options opts = new BitmapFactory.Options(); 
    opts.inSampleSize = originalSize/THUMBNAIL_SIZE; 
    return BitmapFactory.decodeFile(image.getPath(), opts);  
} 
1

使用WebView看看View.getDrawingCache()WebView.capturePicture()View.draw()。不要忘記在繪製之前測量和佈置WebView。如果您使用第一種方法,也會在捕獲後禁用繪圖緩存。

+0

感謝您的回覆@praetorian droid,但我想要所有的html頁面縮略圖。只給​​出當前視圖縮略圖的這些方法 –

+0

將您的頁面加載到WebView中,您將獲得頁面的縮略圖。爲所有頁面執行此操作並使用位圖:根據需要滾動或連接它們。 –