2013-08-30 20 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中,您将获得页面的缩略图。为所有页面执行此操作并使用位图:根据需要滚动或连接它们。 –