android-Style and Themes

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.