Android 有些Moto 360没有加载圆形布局

Android 有些Moto 360没有加载圆形布局,android,wear-os,Android,Wear Os,我编写了一个在圆形和方形手表上运行的应用程序,它有两个布局和一个watchViewStub。 由于moto 360在欧洲销售,我有很多报告称moto 360没有采用圆形布局。使用emulator,即使我更改了区域设置,也无法重现此行为,如此处所述: 所以我想这是我的密码 下面是我如何实现它的: <android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android.com/apk/res/andr

我编写了一个在圆形和方形手表上运行的应用程序,它有两个布局和一个watchViewStub。 由于moto 360在欧洲销售,我有很多报告称moto 360没有采用圆形布局。使用emulator,即使我更改了区域设置,也无法重现此行为,如此处所述: 所以我想这是我的密码

下面是我如何实现它的:

<android.support.wearable.view.WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_camera"
app:roundLayout="@layout/round_activity_camera">
片段用于FragmentViewPager/FragmentGridPagerAdapter。 在我得到Moto360之前,有没有关于如何调试它的想法

编辑

Wear Sdk中的WatchViewStub示例有两种不同的行为,这取决于语言设置,因此我填写了此问题:

重要的

这个问题在不同的岗位上讨论。为了避免重复更新的信息,只有谷歌代码上的问题才会被更新,一旦问题得到解决,我将完成这篇文章:

由于未正确使用WatchViewStub,导致布局膨胀的问题很多。我没有看到足够的以上代码来确切了解,但一个常见的问题是,当您为手表插图注册侦听器时:

    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
            // Need to also call the original insets since we have overridden the original                                                  
            // https://developer.android.com/reference/android/view/View.OnApplyWindowInsetsListener.html                                   
            stub.onApplyWindowInsets(windowInsets);

            return windowInsets;
        }
    });
我看到人们忘记返回windowInsets,或者忘记调用stub.onApplyWindowInsets的情况。这样做的效果是提供方形布局,而不是圆形布局

其他问题是由于忘记将与square.XML相同的XML元素放入round.XML而引起的


您在adb logcat中收到的错误消息是什么?

我有一些关于此错误的信息

出厂复位后与手机配对时,手表切换语言会触发此问题。您可以通过在可穿戴设备上选择与您在手机上使用的语言相同的语言来避免此问题,这样在设备配对后不会发生任何变化

解决此问题的说明:

工厂重置Moto 360。 当可穿戴设备重新启动时,它会询问您想要使用哪种语言。选择与您在手机上使用的语言相同的语言不要选择默认的英语 在手机上,启动Android Wear companion应用程序,从溢出菜单中选择与新可穿戴设备配对的选项。 将手机与Moto 360配对。
谢谢韦恩的帮助。我刚买了一台带有KGW42R的法国Moto 360,我运行了WatchViewStub示例,它显示您的屏幕是矩形的。我将设备重置为English US,然后它会显示一个圆形屏幕。我来填补一个漏洞。再次感谢你,请发布一个bug的链接?那么你是说仅仅改变设备的区域设置就会导致错误发生?我已经用这个问题的链接更新了我的帖子。如果我找到一个解决方法,我会更新这篇文章。我会在内部为你调查这个问题。不幸的是,这个解决方法不能及时工作。重新启动后,手表再次加载方形布局。
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
            // Need to also call the original insets since we have overridden the original                                                  
            // https://developer.android.com/reference/android/view/View.OnApplyWindowInsetsListener.html                                   
            stub.onApplyWindowInsets(windowInsets);

            return windowInsets;
        }
    });