GvrUiLayout

public class GvrUiLayout

A UI layout for stereo rendering.

This includes the following UI elements:

  • A settings button that allows viewer pairing and configuration.
  • A vertical divider element that separates each eye's view.
  • A back button that triggers a user-provided back listener or a default "close" behavior.
  • An optional "transition view" that displays an interstitial until the device is properly oriented.

In general, this class is thread-safe, and can be obtained via getUiLayout() (where it is automatically attached to the View hierarchy).

Public Methods

boolean
isEnabled()
Returns whether the UI layout layer is enabled.
static void
launchOrInstallGvrApp(Activity activity)
Launches or installs the currently configured Google VR settings app.
void
setCloseButtonListener(Runnable listener)
Sets a listener that gets called back when the close button is clicked.
void
setEnabled(boolean enabled)
Sets whether the UI layout layer is enabled.
void
setTransitionViewEnabled(boolean enabled)
Enables/disables the transition view.
void
setViewerName(String viewerName)
Sets the name of the current viewer, used solely to customize the transition view.

Inherited Methods

Public Methods

public boolean isEnabled ()

Returns whether the UI layout layer is enabled.

public static void launchOrInstallGvrApp (Activity activity)

Launches or installs the currently configured Google VR settings app.

Parameters
activity the current Activity. Required to show a dialog fragment.

public void setCloseButtonListener (Runnable listener)

Sets a listener that gets called back when the close button is clicked.

For Daydream-compatible activities, the default close behavior is to finish the activity and navigate back to the 2D Android home launcher. For Cardboard activities, the default close behavior is to simply navigate back.

The client can and should override this if they desire custom behavior, particularly with hybrid VR apps where there are 2D activity components.

Parameters
listener the task to execute when the close button is clicked. A null argument restores the default behavior.

public void setEnabled (boolean enabled)

Sets whether the UI layout layer is enabled.

Parameters
enabled whether to enable the UI layout's appearance. Enabled by default.

public void setTransitionViewEnabled (boolean enabled)

Enables/disables the transition view.

Note: Transition view behavior can vary for Daydream Activities and viewers, and may not respect the user setting.

Parameters
enabled whether to enable the transition view. Disabled by default.

public void setViewerName (String viewerName)

Sets the name of the current viewer, used solely to customize the transition view.

If not provided, a generic viewer name will be used.

Parameters
viewerName the current viewer name