Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 915
Adam Johns Avatar asked Feb 11 '15 16:02

Adam Johns


Video Answer


2 Answers

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:

  • Android Style Resource

  • Android Styles and Themes

  • Android 5.1.0_r5 core source code values

like image 184
LongYC Avatar answered Sep 26 '22 04:09

LongYC


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

like image 40
Diyako Avatar answered Sep 23 '22 04:09

Diyako