Google Glass GDK Theme for XML layout
Asked Answered
W

2

10

Is there a theme that we can use in Eclipse or Android Studio for doing XML layouts? I know we should use:

<style name="CustomTheme" parent="@android:style/Theme.DeviceDefault">

to get the Glass theme on the device, but how about while laying out in the editor?

Wappes answered 22/11, 2013 at 16:50 Comment(2)
Fixed this question so that the XML you typed in originally appears now.Hummocky
It would be great to get an actual answer to this question.Afternoons
A
4

Since it looks like the XML got eaten up in your original post, I'll repeat the tips to get the Glass theme on the device: remove any android:theme attributes that your IDE has automatically inserted, or if you need a custom theme, have it inherit from Theme.DeviceDefault (see GDK: Glass theme and UI widgets).

Eclipse and Android Studio do not yet provide an out-of-the-box exact Glass layout experience. You can approximate it fairly well by creating a device definition in the AVD Manager that matches the screen resolution on Glass (640 × 360, notlong, hdpi) as suggested by this post.

Then, select that device definition in your layout editor. You may also want to select Theme.DeviceDefault.FullScreen.NoActionBar to remove the status bar and action bar in your editor preview.

Arleta answered 22/11, 2013 at 17:2 Comment(3)
Ok, thanks for the response. Still having issues with layouts not appear as they do in Eclipse even with the settings you suggest.Wappes
There are certain theme settings that Glass overrides (such as the text sizes/font weights for the various textAppearance styles, among many others) which will not be known by the IDEs yet. What other specific problems are you seeing? (For the time being, you should also consider using "px" units instead of "dp", despite the warnings that Eclipse/Android Studio may give you. I typically put such dimensions in a dimens.xml file to avoid those warnings.)Arleta
Some images that I am using are not lining up as they are on in eclipse(and other android devices and pre-gdk Glass). I am using margins with "dip" to align certain images and now it is offset. Probably due to different size of text. Thanks again.Wappes
H
2

You might want to look at how I accomplished getting the Glass theme (which is just no theme as discussed in https://developers.google.com/glass/develop/gdk/ui/theme-widgets) in a Hello World app for Glass. Since the ADT in Eclipse creates a Theme by default and assigns it to the application in AndroidManifest.xml, I just had to remove it.

Here is a Git commit that shows this in action: https://github.com/luisdelarosa/HelloGlass/commit/a58208ddef2b9b25ac605735da0dd93860492477

Specifically I looked for this line in AndroidManifest.xml and removed it:

android:theme="@style/AppTheme"

I also removed the res/values/styles.xml since it was not being used anymore - it only had the themes in it.

As for having a graphical editor for Glass layouts, I don't think this is that well supported yet since we are still in Sneak Peek mode. Perhaps once we get to the Developer Preview mode, the Glass team will create editors that will allow us to design for the Glass UI exactly.

Hummocky answered 24/11, 2013 at 6:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.