- Cardboard VR Projects for Android
- Jonathan Linowes Matt Schoen
- 192字
- 2021-07-16 10:54:09
The activity_main.xml file
Our app needs a layout where we'll define a canvas to paint our graphics. The new project created by Android Studio makes a default layout file in the app/res/layout/
folder (using the Android view or app/src/main/res/layout
using the Project view). Find the activity_main.xml
file and double-click on it to edit it.
There are two views of a layout file in the Android Studio editor: Design versus Text, selected by tabs on the lower-left hand side of the window pane. If the Design view tab is selected, you'll see an interactive editor with a simulated smartphone image, a palette of UI components on the left-hand side, and a Properties editor on the right-hand side. We're not going to use this view. If necessary, select the Text tab at the bottom of the activity_main.xml
editor pane to use text mode.
Cardboard apps should run on the full screen, so we remove any padding. We will also remove the default TextView
that we're not going to use. Instead, we replace it with a CardboardView
, as follows:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <com.google.vrtoolkit.cardboard.CardboardView android:id="@+id/cardboard_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" /> </RelativeLayout>
The AndroidManifest.xml
file references the main activity named MainActivity
. Let's take a look at that now.
- Raspberry Pi 3 Cookbook for Python Programmers
- 電腦維護與故障排除傻瓜書(Windows 10適用)
- Applied Unsupervised Learning with R
- 辦公通信設(shè)備維修
- 電腦組裝、維護、維修全能一本通(全彩版)
- 硬件產(chǎn)品經(jīng)理成長手記(全彩)
- AMD FPGA設(shè)計優(yōu)化寶典:面向Vivado/SystemVerilog
- 嵌入式系統(tǒng)中的模擬電路設(shè)計
- LPC1100系列處理器原理及應(yīng)用
- Managing Data and Media in Microsoft Silverlight 4:A mashup of chapters from Packt's bestselling Silverlight books
- Hands-On Deep Learning for Images with TensorFlow
- 單片微機原理及應(yīng)用
- USB應(yīng)用分析精粹:從設(shè)備硬件、固件到主機端程序設(shè)計
- Blender for Video Production Quick Start Guide
- 計算機組成技術(shù)教程