The style acts on a single view or control, extracting common properties for reuse.
There are two ways to inherit a style:
To identify a parent style through the parent
1 < name= "Greentext" parent= "@android: style/textappearance"> 2 <name= "Android:textcolor"># 00FF00</item>3</style>
The name of the parent style is prefixed with "." Connect the name of the new style
1 < name= "codefont.red">2 <Name = "Android:textcolor">#FF0000</item> 3</style>
Among them, the 2nd way can be unlimited connection sub style implementation of multi-level inheritance.
1 < name= "CodeFont.Red.Big">2 <Name = "android:textsize">30sp</item>3 </style>
In the 1th way, Android's restrictions on the 2nd approach are that the referenced style must be defined by itself, or that the parent style and child style must be defined within the same program and cannot refer to a third-party or system style. After all, a reference to the system's style is required to add the android: prefix as the namespace. Second, when using a style, the style defined in the 2nd way must refer to its full name, which means it must contain the full prefix and name:
1 < EditText 2 style = "@style/codefont.red.big" 3 />
Android has no limitations on the 1th way of definition, so all styles defined in the 2nd way can be turned into the 1th type:
1 < name= "Big" parent= "codefont.red">2 <name= "android:textsize">30sp</Item >3</style>
When the parent style is specified with parent, the prefix is no longer functional, just as the name of the style. In other words, the Android style does not support multiple inheritance, only one layer at a to inherit.
Resources
Style inheritance relationship in Android
.
Android Style Inheritance