个人笔记之style
2016-01-03 14:12
483 查看
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- 去掉标题栏 -->
<item name="android:windowNoTitle">true</item>
</style>
<!-- 在样式文件中 可以抽取布局文件中相同的代码 -->
<style name="btn_next">
<item name="android:onClick">next</item>
<item name="android:background">@drawable/button</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentBottom">true</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:drawableRight">@drawable/next</item>
<item name="android:text">下一步</item>
<item name="android:textColor">#000000</item>
</style>
<style name="btn_pre">
<item name="android:onClick">pre</item>
<item name="android:background">@drawable/button</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentBottom">true</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:drawableLeft">@drawable/previous</item>
<item name="android:text">上一步</item>
<item name="android:textColor">#000000</item>
</style>
1.以上是style的例子。将布局文件xml中相同的代码抽取出来统一的放到style.xml中!在布局文件中直接调用style
<Button
style="@style/btn_pre"
/>
<Button
style="@style/btn_next"/>
2.如果在xml布局中需要更改style中的属性,只需要覆盖style中的属性即可!如下:更改了style中的背景和text文字,直接覆盖即可!
<Button
style="@style/btn_pre"
/>
<Button
style="@style/btn_next"
android:text="设置完成"
android:drawableRight="@null"/>
3.style的继承
1).加上parent
<style name="TextViewStyle2" parent="@style/TextViewStyle1">
<item name="android:layout_width">400dp</item>
</style>
2).加点
<style name="TextViewStyle1.test">
<item name="android:layout_width">800dp</item>
</style>
3).还可以多继承:
<style name="TextViewStyle1.test.test">
<item name="android:layout_width">1200dp</item>
</style>
4.theme:影响整个个程序的显示:
<pre name="code" class="html">
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<strong><item name="android:textSize">60sp</item>
<item name="android:typeface">monospace</item></strong>
</style>
相关文章推荐
- MyEclipse Web Project转Eclipse Dynamic Web Project
- MyEclipse常用配置图文教程
- MyEclipse连接MySQL数据库报错解决办法
- 在myeclipse中如何加入jquery代码提示功能
- MyEclipse 6.0.1 6.0GA 6.0M1 5.5GA 5.1.1GA 注册码及高速下载地址
- javascript在myeclipse中报错的解决方法
- eclipse3.2.2 + MyEclipse5.5 + Tomcat5.5.27 配置数据库连接池
- eclipse+myeclipse 环境配置方法
- 设置Myeclipse中的代码格式化、注释模板及保存时自动格式化
- myeclipse安装jQuery插件的方法
- 解决MyEclipse10.7部署报错抛空指针异常问题的方法
- 导致MyEclipse内存不足的原因分析及解决办法
- MyEclipse到期破解代码分享
- myeclipse智能提示设置的实现方法
- 用MyEclipse配置DataBase Explorer(图示)
- 解决MyEclipse中的Building workspace问题的三个方法
- Struts2 入门小程序 -- Myeclipse 9.1下
- SpringMVC入门小程序 -- Myeclipse 9.1下
- SpringMVC+Spring3+Hibernate4
- maven 使用 问题记录