問題:AndroidManifest.xml 中 <application android:theme="..."> 與 <activity android:theme="..."> 同時設定,最終套用哪個?
Activity 主題優先於 Application 主題(後設定者勝出,具體為「較具體範圍覆蓋較廣泛範圍」)。
android:theme 屬性)→ 單一 View 覆蓋。<application android:theme="@style/AppTheme">
<activity android:name=".MainActivity" android:theme="@style/NoActionBarTheme">
</activity>
</application>
MainActivity 會套用 NoActionBarTheme,其他 Activity 用 AppTheme。
setTheme(R.style.Xxx) 在 super.onCreate() 前呼叫 → 同樣覆蓋。@style/ChildTheme 繼承 @style/ParentTheme,屬性疊加。「就近原則」:越接近元件的 theme 設定優先級越高。