Android中theme.xml与style.xml的区别
一、相同点
两者的定义相同、继承方式也相同
<?xml version="1.0" encoding="utf-8"?>
<resources> <!--
继承方式
1、parent
通过parent属性用来继承Android已经定义好的style
比如:parent="android:Theme.Dialog" 或 parent="@android:style/Theme.Dialog"
2、继承自定义的style,可以使用parent或 . 的方式
比如 <style name="parent.child"> View中调用时 style="@style/parent.child"
或 <style name="child" parent="@style/parent.child"> View中调用时 style="@style/child"
或 <style name="child" parent="parent.child"> View中调用时 style="@style/child"
-->
<style name="myDialog" parent="android:Theme.Dialog">
<item name="android:windowBackground">@mipmap/ic_launcher</item>
</style> <style name="parent">
<item name="android:textSize">30sp</item>
<item name="android:text">parent</item>
</style>
<!-- .的继承方式 -->
<style name="parent.child">
<item name="android:text">child</item>
<item name="android:textColor">#ff00ff</item>
</style> <!-- parent的继承方式-->
<style name="child" parent="@style/parent.child">
<item name="android:text">childs</item>
</style>
</resources>
二、不同点
一)、使用的地方不同
1.Theme 是用来设置应用全局主题风格的,对整个应用或某个Activity存在影响。 5.0 上可以让你局部的调整设计风格;
1) AndroidManifest.xml中:
<application android:theme="@android:style/theme">
<activity android:theme="@android:style/theme">
2) 在Activity通过代码设置:
setTheme(R.style.theme);
注意必须在setContentView()之前设置才有效
2.Style 主要是用在View上的,当你在view上设置 style 的时候,LayoutInflater会读取该 style 的内容并在任意单独设置的样式之前把该内容设置到 AttributeSet中。比如:
<EditText
android:layout_height="wrap_content"
android:text="EditText"
style="@style/Title"
android:layout_width="fill_parent"
android:id="@+id/editText1"/>
二)、 在R.attr定义中以window开头的一些属性只对theme有效。
三)、如果一个应用使用了theme,同时应用下的view也使用了style,那么当theme与样式style发生冲突时,style的优先级高于主题
Android中theme.xml与style.xml的区别的更多相关文章
- android 中theme.xml与style.xml的区别
from://http://liangoogle.iteye.com/blog/1848448 android 中theme.xml与style.xml的区别: 相同点: 两者的定义相同. <r ...
- 在Android中把内容写到XML文件中
在Android中把内容写到XML文件中 saveXmlButton.setOnClickListener(new OnClickListener() { @Override public void ...
- Android中Intent传值与Bundle传值的区别详解
Android中Intent传值与Bundle传值的区别详解 举个例子我现在要从A界面跳转到B界面或者C界面 这样的话 我就需要写2个Intent如果你还要涉及的传值的话 你的Intent就要写两 ...
- android 中theme和style的语法相关
1.theme和style都是一组属性的集合,用于定义文本.颜色.大小等显示风格.他们都是资源,可以用android系统级别的一些默认的风格和主题资源,你也可以自定义你自己的主题和风格资源. 2.自定 ...
- Android 中自定义控件和属性(attr.xml,declare-styleable,TypedArray)的方法和使用
一. 在res/values 文件下定义一个attrs.xml 文件.代码如下: <?xml version="1.0" encoding="utf-8" ...
- Android中通过代码获取arrays.xml文件中的数据
android工程res/valuse文件夹下的arrays.xml文件中用于放各种数组数据,比如字符串数组.整型数组等,数组中的数据可能是具体的值,也有可能是对资源数据的引用,下面针对这两种情况通过 ...
- Android主题theme和风格style总结
用到了Android的主题和风格,感觉很多地方需要总结和记录下来.其实主题和风格是有很大的作用的,特别是界面要求比较高的客户端. Style:是一个包含一种或者多种格式化属性的集合,我们可以将其用为一 ...
- Android 中pid与uid的作用与区别
PID:为Process Identifier, PID就是各进程的身份标识. 程序一运行系统就会自动分配给进程一个独一无二的PID.进程中止后PID被系统回收,可能会被继续分配给新运行的程序,但是在 ...
- ANDROID 中UID与PID的作用与区别
PID:为Process Identifier, PID就是各进程的身份标识,程序一运行系统就会自动分配给进程一个独一无二的PID.进程中止后PID被系统回收,可能会被继续分配给新运行的程序,但是在a ...
随机推荐
- ASP.NET MVC 文件异步上传问题处理
最近在做一个网站,用asp.net MVC4.0来开发,今天遇到了个小问题,通过查找相关渠道解决了,在这里把这个问题写出来,问题非常简单,不喜勿喷,mark之希望可以给遇到相同问题的初学者一点帮助.我 ...
- nginx 站点80跳443配置
server { listen 80; server_name www.furhacker.cn; location /{# return 301; rewrite ^(.*)$ https://$h ...
- 03-StreamReader和StreamWriter的案例
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- 第一个androidAPP项目总结—数据请求
1.使用 ShenBuLuoHttpImpl.getMHttpImpl(context).getAddressList(mod.getCouponCode(), new HttpAfter() { @ ...
- mysql数据库编码
MySQL数据库默认的编码是: character set :latin1 collation : latin1_swedish_ci 查看MySQL支持的编码: mysql> show cha ...
- tips [终端]
pbcopy 命令:Place standard output in the clipboard. $ pbcopy < ~/.ssh/id_rsa.pub
- CSS布局注意(纯属个人总结)
和CSS样式有关多用class,和后台数据有关多用id. 1.使用绝对定位时(偏移量如:top,left...),如果父类没有相对定位,使用绝对定位的元素是相对根元素(即<html>标签) ...
- Mybatis的学习总结(一)——使用配置文件实现增删改查
在使用Mybatis作为持久层来进行操作数据库,有很多的操作都是一样的,基本上都是先得到session,然后调用session提供的相关方法进行操作,接着提交session,最后关闭session.那 ...
- javascript中的事件问题
事件的类型: (1)鼠标事件: click用户点击鼠标时发生,当用户的焦点在按钮上,并按了回车键,同样会触发这个事件 dbclick 用户双击鼠标左键时发生 mouseover 鼠标移出某个 ...
- JS函数与call()apply()详解
JavaScript中的每个函数都是一个对象. 因为函数都是对象,它们有自己的属性和方法.我们可以把它们看作数据(data). 函数和方法的区别? 函数立足于它们自己(例如:alert()), 而方法 ...