0

This is my first try with Android Studio, i have used Eclipse for my previous applications. I am create an application for Google Wear and i want to include the function to automatic change the layout depending on square or round watch.

And this is actually the default code but i cant get it to work, maybe someone could point me in the right direction.

It always uses the square layout, i have tried it on actual round watch (Moto 360) and also in the layout windows in Android Studio and even if i pick the Wear Round option it still uses the square layout.

Activity.java

private TextView mTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_wear_activity);
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mTextView = (TextView) stub.findViewById(R.id.text);
        }
    });
}

rect_main_wear_activity.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=".MainWearActivity"
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>

round_main_wear_activity.xml

<?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=".MainWearActivity"
tools:deviceIds="wear_round">

<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="@string/hello_round" />
</RelativeLayout>

main_wear_activity.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_main_wear_activity"
app:roundLayout="@layout/round_main_wear_activity"
tools:context=".MainWearActivity"
tools:deviceIds="wear">
</android.support.wearable.view.WatchViewStub>
Kristoffer Isaksson
  • 881
  • 1
  • 6
  • 15
  • I rebooted the Moto 360 and now it works on that device, still same problem in Android Studio, maybe its not possible to test this function there? – Kristoffer Isaksson Sep 26 '14 at 18:13

1 Answers1

2

In terms of the AndroidWear Round emulator this was clearly a bug. Today Google released the SDK Tools 23.0.4 as well as a new ARM EABI v7a system image (rev2) which should fix the bug you've described in your post.

Here's the "official" statement by Wayne Piekarski:

The Android Developer Tools team has just released SDK Tools 23.0.4. This version contains an update for the AndroidWearRound emulator, so that there is now one correct profile instead of the three different profiles that existed before. So go to the Android SDK Manager and download the update to SDK Tools 23.0.4, as well as Android Wear ARM EABI v7a System Image rev. 2, and then recreate your AndroidWearRound AVD in the AVD Manager.

I've just tested this and I can confirm that this bug is solved. However it's still not possible to use the Host GPU. (Problem is described here)

Community
  • 1
  • 1
reVerse
  • 35,075
  • 22
  • 89
  • 84