Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML @style in parent

In the android examples style-parents are defined like this

 <style name="GreenText" parent="@android:style/TextAppearance">

but in the android sources i find

<style name="Widget.AppCompat.ActionBar.TabText" parent="Base.Widget.AppCompat.ActionBar.TabText">

whats the difference when i prefix with @style and @android:style or not?

like image 509
wutzebaer Avatar asked Feb 17 '16 10:02

wutzebaer


1 Answers

In general, if you put "@android" in front of something, it means that you're looking for a resource defined in android package, not in your project.

For instance, if you're trying to get a color:

android:background="@android:color/holo_red_dark"

This will get the Android holo_red_dark color. You don't have this color defined in your project.

android:background="@color/my_red_color"

This will get your "my_red_color" defined in your project.

Same goes for styles.

EDIT: The thing is there is no difference between

parent="@style/MyStyle"

and

parent="MyStyle"

for a style compiled in your project. You might as well just write

<style name="Widget.AppCompat.ActionBar.TabText" parent="@style/Base.Widget.AppCompat.ActionBar.TabText"> 

and it would work.

Thus, taking in account that Base.Widget.AppCompat.ActionBar.TabText is compiled in your project form the support library, you can add it with @style as prefix or without. However, @android:style/TextAppearance is from Android package, and that is why you have to specify @android: as a prefix.

I hope it is clear now

like image 114
DDsix Avatar answered Oct 01 '22 20:10

DDsix