Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 862
nickjm Avatar asked Oct 21 '22 06:10

nickjm


1 Answers

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)
like image 127
Andrew Schuster Avatar answered Oct 23 '22 03:10

Andrew Schuster