style and theme
2013-12-24 15:13
197 查看
今天想写一些关于主题和样式的博客,以方便记录学习的过程和以后的应用今天有个应用要把样式改成明亮的Holo.Light的样式 <activity android:theme="@style/activity_theme" // 这句是定义activity的主题 android:name=".ItemsActivity" android:label="@string/app_name" > 主题又在res文件下的styles.xml中定义<?xml version="1.0" encoding="utf-8"?><resources> <style name="activity_theme" parent="@android:style/Theme.Holo.Light"> // 这行是定义style为明亮的主题 </style> </resources>如
前面是引子,现在系统的根据andorid documents来整理styles 和 theme:一:简介style 是根据web的设计哲学,把样式和内容分开举个例子,layout可以这样
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#00FF00" android:typeface="monospace" android:text="@string/hello" />或者是这样
<TextView style="@style/CodeFont" android:text="@string/hello" />
CodeFont在styles.xml中自己定义比如:
<?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>
二:style的继承关系:
<style name="CodeFont.Red"> <item name="android:textColor">#FF0000</item> </style>这样CodeFont.Red就继承了CodeFont 并且加了颜色
三:style的属性:
<EditText android:inputType="number" ... />你可以把组件的属性设为是输入数字:<style name="Numbers"> <item name="android:inputType">number</item> ...</style>在layout.xml中的EditText中就可以这样<EditText style="@style/Numbers" ... />
相关文章推荐
- (转)Matlab坐标修改 gca
- 职场新人攻略:恰当地让领导了解自己的业绩
- 盗亦有道:汇报工作进度
- asp.net跳转页面的三种方法比较(转)
- iOS 用CALayer实现动画
- 国外酷站设计:15个带给你灵感的作品集网站
- Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy
- 黑马程序员----------------------面向对象的理解
- Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy
- 禁止ScrollView的childview自动滑动到底部
- cocos2d-x 游戏中障碍物的实现原理
- 再议libcurl编程
- PSP结构化分析
- 常见,常用的名词缩写 20131224
- Android事件监听器(Event Listener)
- 不规则div的写法
- kmem
- prepareStatament和Statement和callableStatement的区别
- CSS3 渐变效果
- 写XML配置文件时的一个乱码问题