官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 刚察县| 乐陵市| 珲春市| 博客| 青田县| 平安县| 荃湾区| 太仓市| 义乌市| 固阳县| 正阳县| 渝中区| 大埔县| 江陵县| 太湖县| 华亭县| 台安县| 环江| 汉川市| 承德市| 宕昌县| 靖江市| 肥东县| 茂名市| 城步| 邓州市| 韶关市| 锦屏县| 泽普县| 泰兴市| 屏南县| 东辽县| 龙陵县| 安陆市| 临城县| 宜兰市| 玉溪市| 大名县| 沐川县| 云安县| 高唐县|