Udostępnij za pośrednictwem


Canvas.EnableZ Method

Definition

Enables Z support which defaults to disabled.

[Android.Runtime.Register("enableZ", "()V", "GetEnableZHandler", ApiSince=29)]
public virtual void EnableZ ();
[<Android.Runtime.Register("enableZ", "()V", "GetEnableZHandler", ApiSince=29)>]
abstract member EnableZ : unit -> unit
override this.EnableZ : unit -> unit
Attributes

Remarks

Enables Z support which defaults to disabled. This allows for RenderNodes drawn with #drawRenderNode(RenderNode) to be re-arranged based off of their RenderNode#getElevation() and RenderNode#getTranslationZ() values. It also enables rendering of shadows for RenderNodes with an elevation or translationZ.

Any draw reordering will not be moved before this call. A typical usage of this might look something like:

void draw(Canvas canvas) {
                    // Draw any background content
                    canvas.drawColor(backgroundColor);

                    // Begin drawing that may be reordered based off of Z
                    canvas.enableZ();
                    for (RenderNode child : children) {
                        canvas.drawRenderNode(child);
                    }
                    // End drawing that may be reordered based off of Z
                    canvas.disableZ();

                    // Draw any overlays
                    canvas.drawText("I'm on top of everything!", 0, 0, paint);
                }

</p>

Note: This is not impacted by any #save() or #restore() calls as it is not considered to be part of the current matrix or clip.

See #disableZ()

Java documentation for android.graphics.Canvas.enableZ().

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