Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux 程式設計 >> Linux 程式設計

Android 布景主題 theme 設計

Android 的 theme 是比 style 更大範圍的 UI 美化機制,可套用到整個應用程式或單一 Activity,例如隱藏標題列、變更背景顏色與整體視覺風格。

定義 theme

在 style.xml 中新增:

<style name="myTheme">
    <item name="android:windowNoTitle">true</item>
    <item name="android:background">#087832</item>
</style>

套用到應用程式

在 AndroidManifest.xml 的 application 節點加入 theme 屬性:

<application
    android:theme="@style/myTheme"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name">
    ...
</application>

若只想套用到單一 Activity,也可在 activity 標籤中設定 android:theme。theme 與 style 搭配使用,能讓 Android 介面更具一致性與品牌感。

Copyright © Linux教程網 All Rights Reserved