Android Style Syntax @android vs android
NickName:Adam Johns Ask DateTime:2015-02-12T00:58:53

Android Style Syntax @android vs android

What is the difference between

<style name="AppTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

And

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

Notice the difference in the parent syntax of using @android:style/ vs just using android:.

I have already seen What's the difference between “?android:” and “@android:” in an android layout xml file? but note that my example doesn't include the question mark.

Copyright Notice:Content Author:「Adam Johns」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28460031/android-style-syntax-android-vs-android

Answers
LongYC 2015-04-14T17:31:06

They give the same results.\n\nThe [package:]resource syntax (sugar?) is probably easier and even gets autocomplete on Android Studio. The parent attribute is used for inheritance, thus the value must be a style resource when the attribute is coming from a style element. You can even use it with your own package, e.g. com.example.mypsyapp:Oppagangnamstyle.\n\nThe @[package:]type/resource syntax is valid for other non-style resources, e.g. @android:drawable/bottom_bar and @string/my_string_id in layout XML. In these cases, the @ is needed to tell that whether the value is a literal string or a reference to a resource.\n\nPotential useful links:\n\n\nAndroid Style Resource\nAndroid Styles and Themes\nAndroid 5.1.0_r5 core source code values\n",


More about “Android Style Syntax @android vs android” related questions

Android Style Syntax @android vs android

What is the difference between &lt;style name="AppTheme" parent="android:Theme.Holo.Light"&gt; &lt;item name="android:actionBarStyle"&gt;@style/MyActionBar&lt;/item&gt; &lt;/st

Show Detail

Android style - difference between @style, android:, @android:style, etc

In android developer examples, blogs, etc, I have seen multiple prefixes for the values of style attributes. Can someone please describe when to use what? For example, what is the difference between

Show Detail

Style android spinner

I'm trying to get my android app a bit more stylish and have made some progress but the spinner dropdown are giving me trouble. I've got a screenshot to show you the problem: What I want is the wh...

Show Detail

Theaming and style in Android

I style a theme using Android asset studio. and i set my app theme in my manifest file. here my all layouts background color is white i want to change that into some other color. i need to mention ...

Show Detail

Style problems with android

I am learning Android programing, but making one exercise i get a problem. The Excersice is that i need to do is work with styles, So i update the res/values/style.xml file with: &lt;resources&g...

Show Detail

inheritance with android style

I have defined red color to contentBg style for TextView. Can i change the TextView color red to blue by changing or renaming style name myContentNew from the parent style? The TextView style name-

Show Detail

Android EditTextPreference style

In my app in setings I use EditTextPreference , and on android API uder 11 edittext field has black background and black text color. How can I chenge EditTextPreferences background color ? I trie...

Show Detail

Syntax highlight in java for android

I want to build an notepad-style application on android that will have syntax highlighting. But when I search around the web, I find the syntax highlighting can be done only through use of an awt c...

Show Detail

Android Style Inheritence

My app has text that can be either black or white; small, medium, or large; and bold or not bold. I can't figure out a way to make styles for covering all bases without resorting to just including ...

Show Detail

android what is the difference between Android Support Repository vs Android Support Library vs Google Repository vs Google Play Services

Can somebody explain me please what is the difference between Android Support Repository vs Android Support Library vs Google Repository vs Google Play Services? My understanding is that Google

Show Detail