Differences between android Theme and style-style and Theme

Source: Internet
Author: User

Style and Theme are often used in projects, but they are never considered the difference. They only copy and copy them. Sometimes they are still confused. In order to say goodbye to confusion, the differences and usage of the two are summarized for your reference.

I. Scope

Theme is for the form level and changes the form style.

The Style is for the form Element level. It changes the Style of the specified control or Layout.

Ii. Usage

Theme

1. Create the themes. xml or styles. xml file under res \ values \.

2. Add Node (root node)

3. Add a custom style

4. (1) In the AndroidManifest. xml file, specify the theme attribute for the Activity (recommended)

(2) The setTheme function must be called before setContentView when the Activity is created)

 

 

5. The Theme provided by the system

Android: theme = "@ android: style/Theme. dialog "// display an Activity as the Dialog box mode android: theme =" @ android: style/Theme. noTitleBar "// do not display the app title bar android: theme =" @ android: style/Theme. noTitleBar. fullscreen "// The title bar of the application is not displayed, and the full screen android: theme =" @ Theme. light "// The background is white android: theme =" Theme. light. noTitleBar "// There is no title bar in the white background. android: theme =" Theme. light. noTitleBar. fullscreen "// white background, no title bar, full screen android: theme =" Theme. black "// background Black android: theme =" Theme. black. noTitleBar "// There is no title bar in the black background. android: theme =" Theme. black. noTitleBar. fullscreen "// black background, no title bar, full screen android: theme =" Theme. wallpaper "// use the system desktop as the application background android: theme =" Theme. wallpaper. noTitleBar "// use the system desktop as the background of the application, and there is no title bar android: theme =" Theme. wallpaper. noTitleBar. fullscreen "// use the system desktop as the background of the application, without a title bar, full screen

6. common attributes

 
  @android:drawable/screen_background_dark
   
 
  @null
   
 
  false
   
 
  false
   
 
  false
   
 
  @android:drawable/title_bar_shadow
   
 
  @android:style/WindowTitle
   
 
  25dip
   
 
  @android:style/WindowTitleBackground
   
 
  @android:style/Animation.Activity
   

Style

1. Create the styles. xml file under res \ values \

2. Add Node (root node)

3. Add a custom style

4. Add the style attribute to a specific control or layout.

 
     
 


Example:

The Tips interface, bubble window, and glass effect when many programs are started


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + tprc68jnz8kjuw.vcd4kpha + Signature = "brush: java;"> import android. app. activity; import android. OS. bundle; import android. view. windowManager; public class BlurThemeActivity extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // Have the system blur any windows behind this one. getWindow (). setFlags (WindowManager. layoutParams. FLAG_BLUR_BEHIND, WindowManager. layoutParams. FLAG_BLUR_BEHIND );}}
Themes. xml

 

AndroidManifest. xml

 


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.