---
title: "android 中theme.xml与style.xml的区别"
author: "liangoogle"
date: "2013-04-16T19:03:30Z"
tags: []
categories: ["移动开发"]
slug: "android-theme-xml-style-xml"
draft: false
lastmod: "2013-04-16T19:09:06Z"
id: 1848448
url: "https://liangoogle.iteye.com/blog/1848448"
---

**android 中theme.xml与style.xml的区别：**

**相同点：**

两者的定义相同。

1. &lt;resources&gt;
2. &lt;stylename="theme"parent="android:Theme.Black"&gt;
3. &lt;itemname="android:windowNoTitle"&gt;true&lt; /item&gt;
4. &lt;itemname="android:textSize"&gt;14sp&lt; /item&gt;
5. &lt;itemname="android:textColor"&gt;#FFFF0000&lt; /item&gt;
6. &lt; /style&gt;
7. &lt; /resources&gt;

**不同点：**

一、使用的地方不同

        1.theme.xml：对整个应用或某个Activity存在全局性影响。

 

                    AndroidManifest.xml中：

                    &lt;application android:theme="@android:style/theme"&gt;，

                    &lt;activity android:theme="@android:style/theme"&gt;，

 

                   application 和  activity  java中：setTheme(R.style.theme);  

         2 style.xml：用在单独的View。

 

                 &lt;EditText android:layout\_height="wrap\_content"

                   android:text="EditText"

                   style="@style/Title"

                   android:layout\_width="fill\_parent"

                   android:id="@+id/editText1"&gt;&lt;/EditText&gt;

二、 在R.attr定义中以window开头的一些属性只对theme有效。

三、如果一个应用使用了theme，同时应用下的view也使用了style，那么当theme与样式style发生冲突时，style的优先级高于主题。