Adam Johns
Adam Johns

Reputation: 36373

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.

Upvotes: 5

Views: 712

Answers (2)

Diyako
Diyako

Reputation: 671

I think that there is no particular difference when called in style.xml. , but : Make a layout and place a textview there. Set this code android: textColor = "? Android: textColorSecondary" inside the textview. When using @android, you can only colorize the text that you created in src. But when you use android, you'll see a lot of code opened from the Android framework. To understand more, please check the attrs.xml file

Upvotes: 3

LongYC
LongYC

Reputation: 475

They give the same results.

The [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.

The @[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.

Potential useful links:

Upvotes: 3

Related Questions