【Android開發基礎】應用介面主題Theme使用方法

來源:互聯網
上載者:User

標籤:

主題Theme就是用來設定介面UI風格,可以設定整個應用或者某個活動Activity的介面風格。在Android SDK中內建了下面的Theme,可以按標題列Title Bar和狀態列Status Bar是否可見來分類:

這些主題可以應用到整個應用Application範圍或者某個活動Activity範圍中。

應用Application範圍
在AndroidManifest.xml中的application節點中設定theme屬性,主題theme應用到整個應用程式中。
<application
    Android:icon=”@drawable/icon”
    Android:icon=”@string/app_name”
    Android:icon=”@android:style/ Theme.Black.NoTitleBar”>

活動Activity範圍
使用Java代碼或者在AndroidManifest.xml中對活動Activity的主題進行設定,主題僅應用到當前活動中。
在AndroidMainifest.xml設定方法:
<activity
android:name=“.About”
android:label=“@string/app_name”
android:theme=“@android:style/ Theme.Black.NoTitleBar” >

使用java代碼進行設定,在當前活動Activity的onCreate中進行設定:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.main);
}

【Android開發基礎】應用介面主題Theme使用方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.