Styles and Themes

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

时间: 2024-12-25 01:48:14

Styles and Themes的相关文章

Android官方文档之User Interface(Styles and Themes)

User Interface(以下简称UI)是任何可以向用户展示.与用户交互的图形界面.Android提供了大量预定义的UI组件( a variety of pre-built UI components),比如Layout资源,除此之外,Android还提供了特殊的UI模型,如dialogs.notifications.menus 等. 从本文起,将介绍Android的各种UI资源以及如何自定义UI资源.本文将介绍: <Styles and Themes>: 您还可以参考这些博客文章: &l

Android中文翻译 - Styles and themes (样式和主题)

本文翻译自:https://developer.android.com/guide/topics/ui/themes.html Style和theme词汇是专用术语,下文直接使用而不翻译. 样式和主题(Styles and Themes) 一个样式(Style)是一个包含了指定样子和格式的作用于视图控件(View)或者窗体(Window)属性集合.一个style可以指定很多属性,比如 高度,填充,字体颜色,字体尺寸,背景色等.一个Style在xml资源文件中定义,并且和在xml中指定的布局区分开

Android篇---Styles和Themes常见用法可能疑点小结

1.style和theme的区别: 简而言之,style指的就是安卓中一个UI控件的样式,而themes指的是安卓中一个activity界面或者整个安卓应用整体的样式.theme的范围比style的范围大. 2.style的继承用法:(全由笔者根据官方文档亲测,可放心使用,注意:样式的定义都在/res/values/style.xml中,而样式的使用在activity的布局文件里) 对于继承安卓原装style,用法如下代码块,代码的意思是将安卓系统自带的TextAppearance样式中的tex

Android中的样式和主题(Styles and Themes)

样式(style),是为一个视图(View)或窗体(window)指定形状和格式的属性集.一个样式能够指定的属性包括高度.内边距.字体颜色.字体大小.背景颜色等等.样式被定义在一个XML资源文件中,跟设置布局的XML资源文件是分开的. Android中样式的设计哲学跟web设计中的CSS(层叠样式表)相似,就是想办法让设计和内容分隔开来. 例如,通过使用样式(style),你可以将下面的XML布局: <TextView android:layout_width="fill_parent&q

android api 指南-Styles and Themes

style是一些属性值得集合,这些属性值用来指定一个view 或者 window 的外观和格式.style可以只指定height,padding,font color,font size,background color,和很多其他属性.style 定义在xml资源文件中,与layout xml 文件独立开的.android中的style与web中的css有相似的设计哲学-允许设计样式和内容的分离. 例如,使用style,你可以将这样的 layout XML: <TextView android

Styles and Themens(1)详述

Styles and Themes IN THIS DOCUMENT Defining Styles Inheritance Style Properties Applying Styles and Themes to the UI Apply a style to a View Apply a theme to an Activity or application Select a theme based on platform version Using Platform Styles an

Android中文翻译 - 主题(themes )介绍

译者注:theme(主题)和style(样式)是专用术语,下面对这两个词汇不在使用中文词汇. theme 是安卓的一种机制,用于为应用程序和activity提供一致的样式(style).样式style规范了组成用户图形接口的一些元素的可视化属性.比如颜色( color),高度,填充,字体尺寸.为了在平台中所有的APP应用之间,提供比较大的结合性.安卓提供了两个系统主题样式,这样当你构建应用时就可以选择: Holo Light Holo Dark 在帮助你构建APP时应用这些主题,适应普遍的安卓可

Android的Style和Theme 译文

Style 是Window和View的一种外观和格式的属性集合.它可以作为高度,间距,字体大小,背景颜色等属性.Style是一种 xml 资源文件,放在和布局文件不同的文件夹里: Style 的设计理念和 Web一脉相承--即它们都允许你把内容和样式分离. 例如,你用Style可以把下面这个xml文件: <TextView android:layout_width="fill_parent" android:layout_height="wrap_content&quo

【转】Android开源项目 分类 便于查看

之前转载了一个开源项目的文章,发现那些都是没有系统的总结,这里又转载一篇有系统总结的文章. Android开源项目系列汇总已完成,包括: Android开源项目第一篇——个性化控件(View)篇 Android开源项目第二篇——工具库篇 Android开源项目第三篇——优秀项目篇 Android开源项目第四篇——开发及测试工具篇 Android开源项目第五篇——优秀个人和团体篇 Android开源项目第一篇——个性化控件(View)篇 主要介绍那些不错个性化的View,包括ListView.Ac