What is the relation of theme and it's derived theme.

时间:2023-03-09 04:10:07
What is the relation of theme and it's derived theme.

You know, a theme can derive from other theme in two ways: xx.xxx implicit way and parent="xxx" explicit way.

But, what will hapen if we define a theme together with two ways. We demonstrate in the following code fragment:

    <style name="baseColor">
<item name="android:textColor">#FF0000</item>
<item name="android:textSize">40sp</item>
</style> <style name="secondColor">
<item name="android:textColor">#0080ff</item>
</style> <style name="baseColor.text" parent="secondColor">
</style>

If you apply the style  "basecolo.text" to a TextView, you will find the fact that "baseColor.text" derived from "secondColor", no attr in "baseColor" is derived. That is, if both implicit and explicit way exist, explicit way work.

But, if you remove the parent sequence, the "baseColor.text" will derive from "baseColor", like following,  implicit way work.

<style name="baseColor.text">
</style>