Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of Style and Theme in Android

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the role of Style and Theme in Android". In daily operation, I believe that many people have doubts about the role of Style and Theme in Android. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what is the role of Style and Theme in Android?" Next, please follow the editor to study!

Style and Theme are mainly used to beautify Android applications, optimize interactive pages, make full use of various styles and theme resources, and develop various styles of Android applications.

Style

When we need to specify similar formats for a large number of components, such as fonts, colors, background colors, etc., if we choose to specify these properties repeatedly for View components every time, it will undoubtedly result in a sharp increase in workload, and there is no reason for code maintenance and visibility.

Management formats similar to Word and PPT: a style is equal to a collection of formats, and if you set a piece of text to use a style, then all formatting of that style will be applied to the text as a whole. A style is relative to a collection of multiple formats, and other UI components specify the style through the style property, which is equivalent to applying all the formats contained in the style to the UI component at the same time.

Define style resources:

11sp # 32d # 116 26dp # 005

Then use in the layout page:

Theme

Similar to style resources, the XML of theme resources is also placed in the same directory as style resources

But there is a real difference between theme resources and style resources: themes cannot work on a single View component, and principals should work on all Activity in the entire application, or on a specified Acitivity. The format of the theme definition should be the format that changes the appearance of the window, such as window title, window border, etc.

Define theme resources:

True true @ drawable/window_border @ drawable/star

Write in the Android code:

Public vod onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setTheme (R.style.CrazyTheme); setContentView (R.layout.main);}

Finally, add theme to AndroidManifest.xml.

.... At this point, the study on "what is the role of Style and Theme in Android" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report