Search code examples
androidandroid-resourcesandroid-framework

What is "android:" prefix mean in android framework-res module


I copy the this code from the styles.xml file in framework-res module

<style name="Theme">

    <item name="colorForeground">@android:color/bright_foreground_dark</item>
    <item name="colorForegroundInverse">@android:color/bright_foreground_dark_inverse</item>
    <item name="colorBackground">@android:color/background_dark</item>

.

<style name="Theme.Black">
    <item name="android:windowBackground">@android:color/black</item>
    <item name="android:colorBackground">@android:color/black</item>
</style>

As you see, they all have a attribute name which's value is windowBackground. But the formar has a android: and the latter doesn't. Is it really necessary to write a android: prefix in android framework?


Solution

  • Found this to be an interesting question and tried exploring to find the answer.. This is what I found..

    from: http://developer.android.com/guide/topics/resources/style-resource.html

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style
            name="style_name"
            parent="@[package:]style/style_to_inherit">
            <item
                name="[package:]style_property_name"
                >style_value</item>
        </style>
    </resources>
    

    item - Defines a single property for the style. Must be a child of a element. attributes: name Attribute resource. Required. The name of the style property to be defined, with a package prefix if necessary (for example android:textColor).

    from: http://developer.android.com/guide/topics/manifest/manifest-intro.html

    Resource values Some attributes have values that can be displayed to users — for example, a label and an icon for an activity. The values of these attributes should be localized and therefore set from a resource or theme. Resource values are expressed in the following format,

    @[package:]type:name
    

    where the package name can be omitted if the resource is in the same package as the application, type is a type of resource — such as "string" or "drawable" — and name is the name that identifies the specific resource. For example: Values from a theme are expressed in a similar manner, but with an initial '?' rather than '@':

    ?[package:]type:name
    

    And finally, I tried giving the attributes without android:, and it threw an exception, though it compiled successfully.