Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android studio Android Wear自动布局_Android Studio_Wear Os - Fatal编程技术网

Android studio Android Wear自动布局

Android studio Android Wear自动布局,android-studio,wear-os,Android Studio,Wear Os,这是我第一次尝试Android Studio,我在以前的应用程序中使用了Eclipse。 我正在为Google Wear创建一个应用程序,我想包括根据方形或圆形手表自动更改布局的功能 这实际上是默认代码,但我无法让它工作,也许有人可以给我指出正确的方向 它总是使用方形布局,我在实际的圆形手表(Moto 360)上试过,在Android Studio的布局窗口中也试过,即使我选择了耐磨圆形选项,它仍然使用方形布局 Activity.java private TextView mTextView;

这是我第一次尝试Android Studio,我在以前的应用程序中使用了Eclipse。 我正在为Google Wear创建一个应用程序,我想包括根据方形或圆形手表自动更改布局的功能

这实际上是默认代码,但我无法让它工作,也许有人可以给我指出正确的方向

它总是使用方形布局,我在实际的圆形手表(Moto 360)上试过,在Android Studio的布局窗口中也试过,即使我选择了耐磨圆形选项,它仍然使用方形布局

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>
<?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>
<?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>

round_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>
<?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>
<?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>

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>
<?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>
<?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>

就AndroidWear圆形仿真器而言,这显然是一个bug。今天,谷歌发布了SDK工具23.0.4以及一个新的ARM EABI v7a系统映像(rev2),它将修复您在文章中描述的错误

以下是“官方”声明:

Android开发者工具团队刚刚发布了SDK工具23.0.4。 此版本包含AndroidWearRound emulator的更新,因此 现在有一个正确的配置文件,而不是三个不同的配置文件 以前存在的配置文件。因此,请转到Android SDK管理器并 将更新下载到SDK Tools 23.0.4以及Android Wear ARM EABI v7a系统映像版本。2,然后重新创建您的AndroidWearRound AVD管理器中的AVD


我刚刚测试了这个,我可以确认这个bug已经解决了。但是,仍然无法使用主机GPU。(问题描述)

我重新启动了Moto 360,现在它可以在该设备上工作,在Android Studio中仍然存在同样的问题,可能无法在那里测试该功能?