One, the same point
Both have the same definition and inherit the same way
<?xml version= "1.0" encoding= "Utf-8"?> <resources> <!--inheritance Method 1, parent through the parent genus The sex is used to inherit the style that Android has already defined such as: parent= "Android:Theme.Dialog" or parent= "@android: Style/theme.dialog" 2, inherit the custom Styl E, you can use parent or. such as <style name= "Parent.child" > View when called style= "@style/parent.child" or <style name= "ch Ild "parent=" @style/parent.child "> view is called when style=" @style/child "or <style name=" child "parent=" parent. Child "> View style=" @style/child "--<style name=" Mydialog "parent=" Android:Theme.Dialog "> <item name= "Android:windowbackground" > @mipmap/ic_launcher</item> </style> <style N Ame= "Parent" > <item name= "android:textsize" >30sp</item> <item name= "Android:text" >p Arent</item> </style> <!--. Inheritance--<style name= "Parent.child" > <it EM name="Android:text" >child</item> <item name= "Android:textcolor" > #ff00ff </item> </style> ; <!--How the parent inherits--<style name= "child" parent= "@style/parent.child" > <item name= "Android:tex T ">childs</item> </style> </resources>
Two, different points
A), the use of different places
1.Theme is used to set the app's global theme style, affecting the entire app or an activity. 5.0 can allow you to adjust the design of the local style;
1) in Androidmanifest.xml:
<application android:theme= "@android: Style/theme" > <activity android:theme= "@android: Style/theme" >
2) in the activity through the Code settings:
SetTheme (R.style.theme);
Note must be set before Setcontentview () is valid
2.Style is mostly used on view, when you set the style on the view, Layoutinflater reads the style and sets the content to AttributeSet before any individual style. Like what:
android:layout_height= "Wrap_content" android:text= "EditText" style= "@style/title" android:layout_ Width= "Fill_parent" android:id= "@+id/edittext1"/>
(ii) Some properties beginning with window in the R.ATTR definition are valid only for theme.
Third), if an application uses theme, and the view used in the application also uses a style, the style takes precedence over the theme when theme conflicts with style style.
The difference between Theme.xml and Style.xml in Android