Game Development Reference
In-Depth Information
Listing 11-4. Activity_my.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android.com/apk/
res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect"
app:roundLayout="@layout/round"
tools:context="ch11.project.MainActivity"
tools:deviceIds="wear" >
</android.support.wearable.view.WatchViewStub>
The most important thing to check about this file is the layout style, which in this case is
rectangular:
app:rectLayout= "@layout/rect"
Also check the reference to the wear library:
tools:deviceIds= "wear" >
Every time you create a new wear project, two layout files are created, such as rect.xml and
round , which are used depending on whether the wear device is rectangular or rounded.
Listings 11-5 and 11-6 show the code for these files.
Listing 11-5. rect.xml
<?xml version= "1.0" encoding= "utf-8" ?>
<LinearLayout 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"
android:orientation= "vertical"
tools:context= "ch11.project.MainActivity"
tools:deviceIds= "wear_square" >
<TextView
android:id= "@+id/text"
android:layout_width= "wrap_content"
android:layout_height= "wrap_content"
android:text= "@string/hello_square" />
</LinearLayout>
Search WWH ::




Custom Search