Round Android Wear Emulator uses rectangular layouts

Unfortunately, the Moto360 does not yet work in Europe ...

I run the round Android Wear Emulator and it works fine.

However, when I launch my Android Wear activity (which uses WatchViewStub), the layout used is rect_activy_layout, not the round layout

Does anyone else have this problem or its solution when starting Round Emulator?

thanks

+6
source share
2 answers

There are many problems with bloating layouts caused by improper use of WatchViewStub. I don’t see any code to know for sure, but one common problem is that you register a listener to insert a clock so that you can check if it is round or square inside the 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; } }); 

I see cases where people forget to return windowInsets or forget to call stub.onApplyWindowInsets (). This results in a square layout instead of a round layout.

In addition, 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 will actually create a square emulator. Make sure you have three emulators that you choose second. This error has been fixed in the latest versions of Android SDK Tools 23.0.4, but you may have an older version installed.

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

+1
source

One simple fix is ​​to upgrade the Wear Round emulator to API 22, which is currently missing. I generally found the Wear Round emulator at API level 21 to have some kind of erroneous behavior, until now there have been problems with the Round emulator at API level 22. I think this will fix the problem since I had the same I had a problem at some point (and it was not an emulator configuration problem).

0
source

Source: https://habr.com/ru/post/975589/


All Articles