View.BuildDrawingCache Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
BuildDrawingCache(Boolean) |
Forces the drawing cache to be built if the drawing cache is invalid. |
BuildDrawingCache() |
Calling this method is equivalent to calling |
BuildDrawingCache(Boolean)
Forces the drawing cache to be built if the drawing cache is invalid.
[Android.Runtime.Register("buildDrawingCache", "(Z)V", "GetBuildDrawingCache_ZHandler")]
public virtual void BuildDrawingCache (bool autoScale);
[<Android.Runtime.Register("buildDrawingCache", "(Z)V", "GetBuildDrawingCache_ZHandler")>]
abstract member BuildDrawingCache : bool -> unit
override this.BuildDrawingCache : bool -> unit
Parameters
- autoScale
- Boolean
- Attributes
Remarks
Forces the drawing cache to be built if the drawing cache is invalid.
If you call #buildDrawingCache()
manually without calling #setDrawingCacheEnabled(boolean) setDrawingCacheEnabled(true)
, you should cleanup the cache by calling #destroyDrawingCache()
afterwards.
Note about auto scaling in compatibility mode: When auto scaling is not enabled, this method will create a bitmap of the same size as this view. Because this bitmap will be drawn scaled by the parent ViewGroup, the result on screen might show scaling artifacts. To avoid such artifacts, you should call this method by setting the auto scaling to true. Doing so, however, will generate a bitmap of a different size than the view. This implies that your application must be able to handle this size.
You should avoid calling this method when hardware acceleration is enabled. If you do not need the drawing cache bitmap, calling this method will increase memory usage and cause the view to be rendered in software once, thus negatively impacting performance.
This member is deprecated. The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache layers are largely unnecessary and can easily result in a net loss in performance due to the cost of creating and updating the layer. In the rare cases where caching layers are useful, such as for alpha animations, #setLayerType(int, Paint)
handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas
from either a Bitmap
or android.graphics.Picture
and call #draw(Canvas)
on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as android.graphics.Bitmap.Config#HARDWARE Config.HARDWARE
bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy
API is recommended.
Java documentation for android.view.View.buildDrawingCache(boolean)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
See also
Applies to
BuildDrawingCache()
Calling this method is equivalent to calling buildDrawingCache(false)
.
[Android.Runtime.Register("buildDrawingCache", "()V", "GetBuildDrawingCacheHandler")]
public virtual void BuildDrawingCache ();
[<Android.Runtime.Register("buildDrawingCache", "()V", "GetBuildDrawingCacheHandler")>]
abstract member BuildDrawingCache : unit -> unit
override this.BuildDrawingCache : unit -> unit
- Attributes
Remarks
Calling this method is equivalent to calling buildDrawingCache(false)
.
This member is deprecated. The view drawing cache was largely made obsolete with the introduction of hardware-accelerated rendering in API 11. With hardware-acceleration, intermediate cache layers are largely unnecessary and can easily result in a net loss in performance due to the cost of creating and updating the layer. In the rare cases where caching layers are useful, such as for alpha animations, #setLayerType(int, Paint)
handles this with hardware rendering. For software-rendered snapshots of a small part of the View hierarchy or individual Views it is recommended to create a Canvas
from either a Bitmap
or android.graphics.Picture
and call #draw(Canvas)
on the View. However these software-rendered usages are discouraged and have compatibility issues with hardware-only rendering features such as android.graphics.Bitmap.Config#HARDWARE Config.HARDWARE
bitmaps, real-time shadows, and outline clipping. For screenshots of the UI for feedback reports or unit testing the PixelCopy
API is recommended.
Java documentation for android.view.View.buildDrawingCache()
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.