android 中theme.xml与style.xml的区别
2016-05-25 17:57
375 查看
相同点:
两者的定义相同。
<resources>
<stylename="theme"parent="android:Theme.Black">
<itemname="android:windowNoTitle">true< /item>
<itemname="android:textSize">14sp< /item>
<itemname="android:textColor">#FFFF0000< /item>
< /style>
< /resources>
不同点:
一、使用的地方不同
1.theme.xml:对整个应用或某个Activity存在全局性影响。
AndroidManifest.xml中:
<application android:theme="@android:style/theme">,
<activity android:theme="@android:style/theme">,
application 和 activity java中:setTheme(R.style.theme);
2 style.xml:用在单独的View。
<EditText android:layout_height="wrap_content"
android:text="EditText"
style="@style/Title"
android:layout_width="fill_parent"
android:id="@+id/editText1"></EditText>
二、 在R.attr定义中以window开头的一些属性只对theme有效。
三、如果一个应用使用了theme,同时应用下的view也使用了style,那么当theme与样式style发生冲突时,style的优先级高于主题。
两者的定义相同。
<resources>
<stylename="theme"parent="android:Theme.Black">
<itemname="android:windowNoTitle">true< /item>
<itemname="android:textSize">14sp< /item>
<itemname="android:textColor">#FFFF0000< /item>
< /style>
< /resources>
不同点:
一、使用的地方不同
1.theme.xml:对整个应用或某个Activity存在全局性影响。
AndroidManifest.xml中:
<application android:theme="@android:style/theme">,
<activity android:theme="@android:style/theme">,
application 和 activity java中:setTheme(R.style.theme);
2 style.xml:用在单独的View。
<EditText android:layout_height="wrap_content"
android:text="EditText"
style="@style/Title"
android:layout_width="fill_parent"
android:id="@+id/editText1"></EditText>
二、 在R.attr定义中以window开头的一些属性只对theme有效。
三、如果一个应用使用了theme,同时应用下的view也使用了style,那么当theme与样式style发生冲突时,style的优先级高于主题。
相关文章推荐
- 浅谈 MVP in Android
- Android之TextView效果
- Android根据屏幕宽度,按比例缩放图片(图片)
- (4.6.12.6)Android中<meta-data>的使用
- Android 上传图片到服务器
- 为Android Studio2.1.1增加注释函数
- 【android】:android的工程路径都是啥
- 王学岗自定义控件(一)
- Android GridLayout中元素平分且行充满屏幕(计算器的界面效果)
- OverFlowButton的替换方式
- 【Android】如何获取TextView的控件宽度以及字体宽度
- Android 使用addview生成列表,界面切换时将指定的行数滚动到列表的第一行
- android内存溢出问题
- [置顶] Android自定义ViewGroup(四、打造自己的布局容器)
- Android控件系列之RadioButton&RadioGroup
- Android自定义ViewGroup(四、打造自己的布局容器)
- android蓝牙开发---与蓝牙模块进行通信
- Android技巧之封装Log工具类
- Android 6.0 ConfirmCredential
- Android Studio 2.1.1 更换主题 代码样式