您的位置:首页 > 移动开发 > Android开发

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的优先级高于主题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: