Round Android Wear Emulator使用rect布局

时间:2014-09-20 21:47:03

标签: android android-emulator wear-os

不幸的是,Moto360还没有对欧洲有用......

我正在运行Round Android Wear模拟器,这很好。

然而,当我运行Android Wear Activity(使用WatchViewStub)时,正在使用的布局是rect_activy_layout而不是圆形布局

其他人在运行Round Emulator时遇到此问题或已解决?

由于

2 个答案:

答案 0 :(得分:1)

由于未正确使用WatchViewStub导致布局膨胀存在许多问题。我没有看到任何准确知道的代码,但是一个常见问题是当您为监视插入注册监听器时,您可以在onApplyWindowInsets处理程序中检查它是圆形还是方形:

    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);

            // this is where you would check the WindowInsets for isRound()

            return windowInsets;
        }
    });

我看到人们忘记返回windowInsets但忘记调用stub.onApplyWindowInsets()的情况。这具有给出方形布局而不是圆形布局的效果。

此外,SDK内置了AndroidWearRound模拟器的错误。有三个,如果你创建了错误的,它实际上会创建一个方形模拟器。确保你有三个模拟器,你选择第二个。此错误已在最新的Android SDK工具23.0.4中修复,但可能是您的旧版本。

你能告诉我们你在WatchViewStub周围做的代码吗?

答案 1 :(得分:0)

一个简单的解决方法是将Wear Round模拟器升级到API级别22,现在已经出来了。我一般在API级别21发现Wear Round模拟器有一些错误行为,而到目前为止还没有发现API级别22的Round模拟器有任何问题。我认为这将解决问题,因为我有同样的问题在某些时候我自己(这不是模拟器的设置问题)。