Share via


View.DrawingCacheEnabled Property

Definition

Indicates whether the drawing cache is enabled for this view. -or- Enables or disables the drawing cache.

public virtual bool DrawingCacheEnabled { [Android.Runtime.Register("isDrawingCacheEnabled", "()Z", "GetIsDrawingCacheEnabledHandler")] get; [Android.Runtime.Register("setDrawingCacheEnabled", "(Z)V", "GetSetDrawingCacheEnabled_ZHandler")] set; }
[<get: Android.Runtime.Register("isDrawingCacheEnabled", "()Z", "GetIsDrawingCacheEnabledHandler")>]
[<set: Android.Runtime.Register("setDrawingCacheEnabled", "(Z)V", "GetSetDrawingCacheEnabled_ZHandler")>]
member this.DrawingCacheEnabled : bool with get, set

Property Value

true if the drawing cache is enabled

Attributes

Remarks

Property getter documentation:

Indicates whether the drawing cache is enabled for this view.

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.isDrawingCacheEnabled().

Property setter documentation:

Enables or disables the drawing cache. When the drawing cache is enabled, the next call to #getDrawingCache() or #buildDrawingCache() will draw the view in a bitmap. Calling #draw(android.graphics.Canvas) will not draw from the cache when the cache is enabled. To benefit from the cache, you must request the drawing cache by calling #getDrawingCache() and draw it on screen if the returned bitmap is not null.

Enabling the drawing cache is similar to #setLayerType(int, android.graphics.Paint) setting a layer when hardware acceleration is turned off. When hardware acceleration is turned on, enabling the drawing cache has no effect on rendering because the system uses a different mechanism for acceleration which ignores the flag. If you want to use a Bitmap for the view, even when hardware acceleration is enabled, see #setLayerType(int, android.graphics.Paint) for information on how to enable software and hardware layers.

This API can be used to manually generate a bitmap copy of this view, by setting the flag to true and calling #getDrawingCache().

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.setDrawingCacheEnabled(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.

Applies to

See also