2012年2月20日 星期一

[AndroidLayout] getDrawingCache()

Bitmap
As a map of bits or an array of bits.
This Bitmap class is very useful when we are working with graphics interfaces like Canvas or OpenGL.

Canvas
Canvas we have control of all the pixels.


getDrawingCache()
  • Android has a maximum drawing cache size. If the drawing cache would be bigger than that, getDrawingCache() returns null.
  • getDrawingCache() will call buildDrawingCache() if the drawing cache is enabled. If you want to get the darwing cache without enabling it, just call buildDrawingCache() before calling getDrawingCahce() (and call destroyDrawingCache() when you're done.)
  • 要取得畫面的 cache,先 setDrawingCacheEnabled() 將 cache 開啟,再用 getDrawingCache() 就可以或取得。
  • 使用 getDrawingCache() 時,若 cache 沒有建立,系統會自動呼叫 buildDrawingCache()。若要更新 cache,則可以呼叫 destroyDrawingCache(),才能建立新的; 或是當設 setDrawingCacheEnabled 為 false,系統也會自動把原來的 cache 銷毀。



* Reference
- Converting Views to Bitmap Images in Android
- android - Bitmap from TextView (getDrawingCache) always null - Stack Overflow
- How drawing cache in View works - Android Developers | Google 網上論壇
- 对View DrawingCache的理解 - JYJ_Block_Science and Technology - 博客频道 - CSDN.NET *

沒有留言:

張貼留言