Round Android Wear Emulator使用矩形布局 [英] Round Android Wear Emulator is using rect layouts

查看:41
本文介绍了Round Android Wear Emulator使用矩形布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,Moto360尚未在欧洲使用...

Unfortunately Moto360 is not avail to Europe yet...

我正在运行Round Android Wear模拟器,并且运行正常.

I'm running a Round Android Wear Emulator and this is working fine.

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

However when I run my Android Wear Activity (which uses a WatchViewStub) the layout being used is the rect_activy_layout and not the round layout

在运行Round Emulator时,还有其他人遇到此问题或解决了吗?

Anyone else have this issue or resolved when running Round Emulator?

谢谢

推荐答案

由于未正确使用WatchViewStub而导致布局夸大的问题很多.我看不到任何代码确切地知道,但是一个常见的问题是,当您为监视实例注册一个侦听器时,您可以检查其在onApplyWindowInsets处理程序中是圆形还是方形:

There are many problems with inflating layouts that are caused by not correctly using WatchViewStub. I don't see any code to know exactly, but one common issue is when you register a listener for watch insets so you can check if it is round or square inside your onApplyWindowInsets handler:

    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()的情况.这样的效果是给出正方形布局而不是圆形布局.

I see cases where people forget to return the windowInsets, or forget to call stub.onApplyWindowInsets(). This has the effect of giving a square layout instead of a round layout.

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

Also, there was a bug with the AndroidWearRound emulator built into the SDK. There were three of them, and if you created the wrong one, it would actually create a square emulator. Make sure if you have three emulators, that you pick the second one. This bug has been fixed in the latest Android SDK Tools 23.0.4, but it might be that you have an older version.

您可以向我们展示您在WatchViewStub周围执行的代码吗?

Can you show us the code you are doing around the WatchViewStub?

这篇关于Round Android Wear Emulator使用矩形布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆