android-Style and Themes
the difference between a style and a theme theme
1,theme is for the form level, change the form style
2,style is for the form element level, changing the style of the specified control or layout
two ways to use style
1, create style
Create a styles.xml file under Res/values
Add node (root node)
Add a custom style and its properties:
Format of Style
<style name="MyStyle" parent="指定的父style"
There is no need for Android in front of name:
<item name="ATTR需要设置的属性名">[VALUE设定的值]</>
The Parent property is optional and can inherit the properties of other style, when it is necessary to do a tiny bit of the existing style
This value is very useful when changing.
Instance:
<style name="ChengzhiStyle"> <item name="android:textColor">#FFF0000</item></style>
2, specifying a style for the control
Specify in Layout:
<TextView style="@style/MyStyle"/>
Three Theme Theme
1, how to use:
In the manifest file, specify the theme attribute for the activity (this is the recommended way)
android:theme="@style/AppTheme">
Or when activity creation is called Settheme function (must be called before Setcontentview, deprecated)
@Override protectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置主题 setTheme(R.style.AppTheme); setContentView(R.layout.layout_portrait); }
2, using the system's own theme
Common system theme such as:
3, custom theme
<style name="MyTheme" [parent="继承的主题"] <item name="ATTR">[VALUE]</></style>
4, example of frosted glass effect
Frosted Glass Effect: is the interface that many programs start at first, or the blurred activity interface behind the popup dialog box
@Override protectedvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置毛玻璃效果 getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); }
Copyright NOTICE: Welcome to communicate the error of the article, must be open-minded to answer, QQ872785786
android-Style and Themes