简体   繁体   中英

Test Android Wear apps on phone?

Interestingly enough, I noticed that when developing, I can choose to run a Wear app on the phone instead of a Wear device. It looks the same--just huge, of course.

Based on https://plus.google.com/+AndroidDevelopers/posts/QhWQArNDfS3 , I gather I could use ADB to make the phone screen small enough to do a fair imitation of a rectangular smartwatch...

But what about testing for round Android Wear devices? Is there something I can do to the phone (or a rectangular Android Wear device, for that matter) to make it show as a circle (and even better, identify as a round device to Android Wear) in order to test the round interfaces?

Yes, there's always cutting a round hole out of a page and holding that over the device, but that's obviously far from ideal.

You can test your app on a round emulator. Here are instructions how to do this: https://developer.android.com/training/wearables/apps/creating.html

EDIT: About round and forcing round on a square device: you can try to pretend that the device is round, but it's a little hacky and ugly.

In your Activity you need to implement inset listener and then use reflection to change WindowInsets.mRound field. Then dispatch the insets further down the hierarchy. This will trick your views to think that the device is round.

Check this article about handling square and round: http://gruszczy.blogspot.com/2015/03/handling-round-screens-using.html It describes how insets with the information about device display type are delivered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM