`
jinvasshole
  • 浏览: 770942 次
文章分类
社区版块
存档分类
最新评论

Handling large/high resolution images

 
阅读更多

Google TV devices have higher display resolution. If you provide low resolution or small images in your layouts, they will appear pixelated, fuzzy, or grainy. This is not a good experience for the user. Instead, use high resolution images. Remember, though, that downloading and storing high-resolution images may cause "out of memory" errors. To avoid these errors, follow these tips:

  • Load images only when they're displayed on the screen. For example, are displaying multiple images in a GridView, ListView or Gallery, only load an image when its getView() is called.
  • Call recycle() on Bitmaps that are no longer needed.
  • Use WeakReferences for storing references to Bitmap objects in a in memory collection.
  • If you fetch the images from the network, use AsyncTask to fetch them all at once or as needed. Never do network transactions on the main ("UI") thread. Instead, if possible, fetch all the images at once on a background thread, and store them on the sdcard.
  • Scale down very large images to a more appropriate size as you download them; otherwise, downloading the image may cause an "out of memory" error. Here is sample code that does this scaling while downloading:




  


  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics