O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding an icon to the view

Next, we'll add an icon image to the view.

For now, let's just use a generic icon, such as android_robot.png. A copy of this can be found on the Internet, and there's a copy included with the files for this chapter. Paste the android_robot.png file into your project's app/res/drawable/ folder. Don't worry, we'll be using the actual app icons later.

We want to display both the text and an icon together, so we can add the code in order to add the image views to the addContent method.

In the onCreate method of MainActivity, modify the addContent call to pass the icon as a second parameter:

        Drawable icon = getResources()
            .getDrawable(R.drawable.android_robot, null);
        overlayView.addContent("Hello Virtual World!", icon);

In

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required