Android.Views.View.SetCameraDistance Method

java Example

 float scale = context.getResources().getDisplayMetrics().density;
 view.setCameraDistance(distance * scale);
 

Syntax

[Android.Runtime.Register("setCameraDistance", "(F)V", "GetSetCameraDistance_FHandler")]
public virtual void SetCameraDistance (float distance)

See Also

View.RotationX
View.RotationY

Parameters

distance
The distance in "depth pixels", if negative the opposite value is used

Remarks

java Example

 float scale = context.getResources().getDisplayMetrics().density;
 view.setCameraDistance(distance * scale);
 

Sets the distance along the Z axis (orthogonal to the X/Y plane on which views are drawn) from the camera to this view. 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 view plane can have an affect on the perspective distortion of the view 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 "depth pixels." The default distance depends on the screen density. For instance, on a medium density display, the default distance is 1280. On a high density display, the default distance is 1920.

If you want to specify a distance that leads to visually consistent results across various densities, use the following formula:

The density scale factor of a high density display is 1.5, and 1920 = 1280 * 1.5.

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 12