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

android 中theme.xml与style.xml的区别:

相同点:

两者的定义相同。

  1. <resources>
  2. <stylename="theme"parent="android:Theme.Black">
  3. <itemname="android:windowNoTitle">true< /item>
  4. <itemname="android:textSize">14sp< /item>
  5. <itemname="android:textColor">#FFFF0000< /item>
  6. < /style>
  7. < /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的优先级高于主题。

android 中theme.xml与style.xml的区别: 相同点: 两者的定义相同。
  1. <resources>
  2. <stylename="theme"parent="android:Theme.Black">
  3. <itemname="android:windowNoTitle">true< /item>
  4. <itemname="android:textSize">14sp< /item>
  5. <itemname="android:textColor">#FFFF0000< /item>
  6. < /style>
  7. < /resources>

猜你喜欢

转载自liangoogle.iteye.com/blog/1848448