简体   繁体   中英

How can I specify which layout to use for an Android Wearable?

I have a custom view with an onTouch method that launches another activity with its own xml layout. If I run the program on an emulator that has been scaled to watch size (yes only scaled, normal emulator is fine), it creates an instance of the new activity with both the round and rect layout files. Additionally logcat says eglSurfaceAttrib not implemented.

Because this only happens on scaled emulator, is it just a bug with the emulator? I don't have a real android wear watch yet. Or is there a way to package some attribute with the intent that starts the activity to let it know I want one of the layouts?

Edit: It's having this problem on the emulator regardless of size/shape

The best way to target specific screen sizes or aspect ratios is by using qualifiers for alternate resources .

Based on the developer documentation, using the watch qualifier for your resource will probably do the trick. Your directory hierarchy would look something like this:

src/
res/
    layout/
        (all of your regular layouts)
    layout-watch/
        (all of your Android Wearable layouts)

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