Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAngel Viera
3,293 PointsThis code wasn't working for me in Android Studio 1.1 and I think I know why.
According to Google in their UI Guide here: http://developer.android.com/guide/topics/ui/themes.html
XML styles should look like this: style="@style/CodeFont" without the namespace "android:". If you add the namespace, it will show up correctly in the layout preview, but it won't compile.
2 Answers
Harry James
14,780 PointsHey Angel!
Yes, this is correct! We don't use the android:
prefix for styles (I don't know why but, hey ho) so, this would be what's causing the issue. And that's also pretty strange that it comes up in the preview with it as, it shouldn't actually work!
Edit: Actually after thinking about it, it does make sense. All values don't actually use the android:
prefix because, they're not seen as "Android objects" really, I guess it's just things like the actual text itself (Not the storing of the text though) that's part of Android. So, basically the values we store don't have the android:
prefix.
Angel Viera
3,293 PointsOh, by the way! I forgot to say this, but the reason I posted this was because in the second fill-in-the-blank question of the "Introducing Styles" quiz, it definitely includes the namespace, so that should probably be fixed. Unless I'm missing something.
Harry James
14,780 PointsYep! You're right! I just took a look at this quiz and it does indeed use the wrong attribute.
Ben Jakuben perhaps you could take a look at this at some point? Rather than android:style=""
on the 2nd quiz question, it should just be style=""
:)