2015-02-11 23 views
2

是什麼的Android風格的語法@android VS安卓

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

而且

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

注意在使用@android:style/ VS只是用android:的父語法的差異之間的差異。

我已經看到What's the difference between 「?android:」 and 「@android:」 in an android layout xml file?但請注意,我的示例不包括問號。

回答

0

他們給出了相同的結果。

[package:]resource語法(糖?)可能是更容易,甚至會在Android Studio中的自動完成。 parent屬性用於繼承,因此,當屬性來自style元素時,該值必須是樣式資源。您甚至可以將其與自己的包一起使用,例如com.example.mypsyapp:Oppagangnamstyle

@[package:]type/resource語法對其他非樣式資源有效,例如,在佈局XML中爲@android:drawable/bottom_bar@string/my_string_id。在這些情況下,需要@來確定該值是文字字符串還是對資源的引用。

潛在有用的鏈接: