android 中theme.xml與style.xml的區別


from://http://liangoogle.iteye.com/blog/1848448

 

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的優先級高於主題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM