码迷,mamicode.com
首页 > 其他好文 > 详细

Styles and Themes

时间:2017-01-08 20:02:37      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:ext   androi   nod   resource   src   eve   and   form   int   

Styles and Themes

  A 样式 is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout.

  A theme is a style applied to an entire Activity or application, rather than an individual View (as in the example above). When a style is applied as a theme, every View in the Activity or application will apply each style property that it supports.

 

  To create a set of styles, save an XML file in the res/values/ directory of your project. The name of the XML file is arbitrary, but it must use the .xml extension and be saved in the res/values/ folder.

  The root node of the XML file must be <resources>.

  

  Each child of the <resources> element is converted into an application resource object at compile-time, which can be referenced by the value in the <style> element‘s name attribute. This example style can be referenced from an XML layout as @style/CodeFont

  If you want to inherit from styles that you‘ve defined yourself, you do not have to use the parent attribute. Instead, just prefix the name of the style you want to inherit to the name of your new style, separated by a period. For example, to create a new style that inherits the CodeFont style defined above, but make the color red, you can author the new style like this:

  技术分享

参考:http://www.android-doc.com/guide/topics/ui/themes.html

Styles and Themes

标签:ext   androi   nod   resource   src   eve   and   form   int   

原文地址:http://www.cnblogs.com/tekkaman/p/6262514.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!