【移动开发】Android中Theme和Style的使用
2014-05-06 23:59
417 查看
当我们做项目到一定程度的时候,Android提供给我们的简单的UI控件(虽然后期ADT插件更新中增加了不少)已经不能满足我们的需要,一款成功的软件不仅要功能强大,漂亮的界面同样会吸引不少用户!
这里,我将总结一下Android提供给我们的两个重要的资源:Theme 和 Style。
1.Theme(是针对窗体级别的,可以改变窗体样式)
官方文档
Themes are Android's mechanism for applying a consistent style to an app or activity. The style specifies the visual properties of the elements that
make up your user interface, such as color, height, padding and font size. To promote greater cohesion between all apps on the platform, Android provides three system themes that you can choose from when building apps for Ice Cream Sandwich:
主题是Android的机制被应用一个相同风格的应用程序或Activity中。样式指定了视觉属性的元素装饰你的用户界面,如颜色、高度、填充和字体大小。促进更大的凝聚力在所有平台的应用程序,Android提供了三个系统的主题,您可以选择在构建应用程序选择不同的主题:
Holo Light
Holo Dark
Holo Light with dark action bars
官方图:
![](http://img1.51cto.com/attachment/201307/170651183.png)
![](http://img1.51cto.com/attachment/201307/170651260.png)
![](http://img1.51cto.com/attachment/201307/170651145.png)
1.1.使用
Android系统的themes.xml和style.xml(位于/base/core/res/res/values/)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。以下属性是在Themes中比较常见的,源自Android系统本身的themes.xml:
有人会问从哪里学习这些主题?其实系统就自带了很多,看下图:
![](http://img1.51cto.com/attachment/201307/171730366.jpg)
在AndroidManifest的Application中,点击Theme选项,系统资源里就有相当多的主题供你选择。
A.应用到Application
B.应用到Activity
2.Style(是针对窗体元素级别的,改变指定控件或者Layout的样式)
官方文档:
A style 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.
风格是一个集合的属性用于指定具有一定外观和格式的视图或窗口。一个风格可以指定属性如高度、填充、字体颜色、字体大小、背景色等等。一个样式定义在XML资源,独立于XML指定布局。
Styles
in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.
风格在安卓中的份额就如同级联样式表在web设计中的设计,允许你将内容分割开来设计
2.1简单使用
一个简单地样式
可以在任何相同的地方被引用
2.2定义风格
首先可以在res/values/下创建一个xml,用于定义style(注意:根结点必须是<resources>)
这里我们可以看到,该style的名称为CodeFont,parent后面是父类的style,(当然,我们也可以不用继承父类style),接下来每一个item定义一个属性。定义属性的最好方法就是在api文档里找到这个view的xml属性,比如在EditText中有InputType这个属性,那么在你的style里面你就可以来定义它。
ok! 就是这些了!
本文出自 “狂奔的蜗牛”
博客,出处/article/4262481.html
这里,我将总结一下Android提供给我们的两个重要的资源:Theme 和 Style。
1.Theme(是针对窗体级别的,可以改变窗体样式)
官方文档
Themes are Android's mechanism for applying a consistent style to an app or activity. The style specifies the visual properties of the elements that
make up your user interface, such as color, height, padding and font size. To promote greater cohesion between all apps on the platform, Android provides three system themes that you can choose from when building apps for Ice Cream Sandwich:
主题是Android的机制被应用一个相同风格的应用程序或Activity中。样式指定了视觉属性的元素装饰你的用户界面,如颜色、高度、填充和字体大小。促进更大的凝聚力在所有平台的应用程序,Android提供了三个系统的主题,您可以选择在构建应用程序选择不同的主题:
Holo Light
Holo Dark
Holo Light with dark action bars
官方图:
![](http://img1.51cto.com/attachment/201307/170651183.png)
![](http://img1.51cto.com/attachment/201307/170651260.png)
![](http://img1.51cto.com/attachment/201307/170651145.png)
1.1.使用
Android系统的themes.xml和style.xml(位于/base/core/res/res/values/)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。以下属性是在Themes中比较常见的,源自Android系统本身的themes.xml:
![](http://img1.51cto.com/attachment/201307/171730366.jpg)
在AndroidManifest的Application中,点击Theme选项,系统资源里就有相当多的主题供你选择。
A.应用到Application
官方文档:
A style 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.
风格是一个集合的属性用于指定具有一定外观和格式的视图或窗口。一个风格可以指定属性如高度、填充、字体颜色、字体大小、背景色等等。一个样式定义在XML资源,独立于XML指定布局。
Styles
in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.
风格在安卓中的份额就如同级联样式表在web设计中的设计,允许你将内容分割开来设计
2.1简单使用
一个简单地样式
首先可以在res/values/下创建一个xml,用于定义style(注意:根结点必须是<resources>)
ok! 就是这些了!
本文出自 “狂奔的蜗牛”
博客,出处/article/4262481.html
相关文章推荐
- 【移动开发】Android中Theme和Style的使用
- 跨平台移动开发 Android使用JPush推送消息
- phonegap 开发入门 PhoneGap官方网站上有详细的入门示例教程,这里,我针对使用PhoneGap进行Android移动应用的开发对其官网的Get Started进行一些介绍、补充。 Ste
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- 【Android开发基础】应用界面主题Theme使用方法
- Android开发之定制style和theme
- Android开发技巧——自定义控件之使用style
- android UI进阶之style和theme的使用
- 【移动开发】Android图片异步加载之Android-Universal-Image-Loader使用
- android应用开发 - 应用界面主题Theme使用
- 使用IntelliJ IDEA(androidstudio前身)开发android移动应用前的基本设置,提高开发效率
- 【Android开发基础】应用界面主题Theme使用方法
- 跨平台移动开发_Android 平台使用 PhoneGap 方法
- Android Style开发之Theme
- android游戏开发框架libgdx的使用(十三)—TiledMap中的角色和角色移动
- android UI进阶之style和theme的使用
- Android开发技巧——自定义控件之使用style
- android UI进阶之style和theme的使用
- Android移动开发 ListView使用BaseAdapter与ListView的优化,内存优化处理(转载)