This blog was opened 5 months ago and it has 57 posts now,but the poor thing is by now no one has commented on any articles by now..How miserable and pathetic...Even if I've been writing some bullshit you should at least give me some response...Never mind, I was originally meant to writer to remind myself.

And sometimes I feel a little reluctant to read English than Chinese, even when I carefully read them I feel they are illustrated so clearly even more explicit than many Chinese vague articles.When I learn something from google's developer.android.com , I want to note them here.But I think why, firstly, why should I note them when I can visit them any time on google's website; secondly ,why use Chinese?

There's a proverb in China called "A good memory is not as good as a broken pen point" ,meaning that one would remember something better when he or she write it down.Ok now I decide to write things down when I learn something from android developers.

-------------------------

Styles and Themes:

Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.

For example, by using a style, you can take this layout XML:

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#00FF00"
android:typeface="monospace"
android:text="@string/hello" />

And turn it into this:

<TextView
style="@style/CodeFont"
android:text="@string/hello" />

All of the attributes related to style have been removed from the layout XML and put into a style definition calledCodeFont, which is then applied with the style attribute.  

theme is a style applied to an entire Activity or application, rather than an individual View. When a style is applied as a theme, every View in the Activity or application will apply each style property that it supports. For example, you can apply the same CodeFont style as a theme for an Activity and then all text inside that Activity will have green monospace font.

Define Styles

1.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.(I thought it could be saved in any folder,is it just a recommendation?)

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

3.For each style you want to create, add a <style> element to the file with a name that uniquely identifies the style (this attribute is required). Then add an <item> element for each property of that style, with a name that declares the style property and a value to go with it (this attribute is required). The value for the <item> can be a keyword string, a hex color, a reference to another resource type, or other value depending on the style property. Here's an example file with a single style:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>

-----it's Tomb-sweeping Day , to be continued-----

Inheritance

You can use this to inherit properties from an existing style and then define only the properties that you want to change or add. You can inherit from styles that you've created yourself or from styles that are built into the platform.

For example, you can inherit the Android platform's default text appearance and then modify it:

<style name="GreenText" parent="@android:style/TextAppearance">
<item name="android:textColor">#00FF00</item>
</style>

kind of like the "override" concept  in Java huh..

最新文章

  1. 我的MYSQL学习心得(十六) 优化
  2. 1Z0-053 争议题目解析501
  3. rabbitmq python
  4. zstuoj 4243 牛吃草 ——(二分+两圆交)
  5. [ASP.NET MVC] 使用CLK.AspNet.Identity提供依权限显示选单项目的功能
  6. MyBatis中#,$的用法区别
  7. 【基础知识】Sql和Ado.Net第12天
  8. windows下Qt5.1.0配置android环境搭建 good
  9. Delphi2010中DataSnap技术网摘
  10. DB2 创建数据库
  11. Clojure 学习入门(19)—— 数组
  12. iabtis初探
  13. POJ 1979 DFS
  14. 恶补web之八:jQuery(3)
  15. final model for bioinformatics
  16. php与java通用AES加密解密算法
  17. Java 面试题 == 和 equals 的区别
  18. Python中self和__init__的含义与使用
  19. learning docker steps(4) ----- docker swarm 初次体验
  20. Android Graphviz 安装

热门文章

  1. Java并发学习 &amp; Executor学习 &amp; 异常逃逸 &amp; 同步互斥Best Practice &amp; wait/notify, conditon#await/signal
  2. 1、CRM2011编程实战——清空指定页签以下的全部选项,并对页签以下的指定控件进行操作
  3. 广告制胜无它,顺应人性尔——leo鉴书63
  4. Android自己定义控件
  5. hadoop集群搭建datenode为0问题的解决
  6. 在CentOS 7上构建RAID5、LVM和SAMBAserver(5)——架设SAMBAserver
  7. iOS设计模式 - (2)UML类间关系精解
  8. MOS简介
  9. 抽象类的子类能够new
  10. caffe搭建--caffe- win10 vs2015 编译(支持GPU)--注意在cmake的时候需要根据情况仔细修改配置