Share via


RenderNode.SetCameraDistance(Single) Method

Definition

Sets the distance along the Z axis (orthogonal to the X/Y plane on which RenderNodes are drawn) from the camera to this RenderNode.

[Android.Runtime.Register("setCameraDistance", "(F)Z", "", ApiSince=29)]
public bool SetCameraDistance (float distance);
[<Android.Runtime.Register("setCameraDistance", "(F)Z", "", ApiSince=29)>]
member this.SetCameraDistance : single -> bool

Parameters

distance
Single

The distance in pixels, must always be positive

Returns

True if the value changed, false if the new value was the same as the previous value.

Attributes

Remarks

Sets the distance along the Z axis (orthogonal to the X/Y plane on which RenderNodes are drawn) from the camera to this RenderNode. The camera's distance affects 3D transformations, for instance rotations around the X and Y axis. If the rotationX or rotationY properties are changed and this view is large (more than half the size of the screen), it is recommended to always use a camera distance that's greater than the height (X axis rotation) or the width (Y axis rotation) of this view.

The distance of the camera from the drawing plane can have an affect on the perspective distortion of the RenderNode when it is rotated around the x or y axis. For example, a large distance will result in a large viewing angle, and there will not be much perspective distortion of the view as it rotates. A short distance may cause much more perspective distortion upon rotation, and can also result in some drawing artifacts if the rotated view ends up partially behind the camera (which is why the recommendation is to use a distance at least as far as the size of the view, if the view is to be rotated.)

The distance is expressed in pixels and must always be positive

Java documentation for android.graphics.RenderNode.setCameraDistance(float).

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