2013-10-23 114 views
9

我的應用程序的主題是Light。我可以在操作欄中顯示應用程序圖標,而無需將Theme.Light更改爲Theme.Holo.Light。Android - 如何在行動欄中顯示應用程序徽標

style.xml

<style name="AppBaseTheme" parent="android:Theme.Light"> 

AndroidManifest.xml中

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:logo="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 

的風格 「的EditText」 和等對象更漂亮與Theme.Light,那爲什麼我不想改變它。有可能或者我應該爲每個對象編寫風格並更改應用程序的主題。

回答

9

這對我的作品與Theme.Light

android.support.v7.app.ActionBar menu = getSupportActionBar(); 
menu.setDisplayShowHomeEnabled(true); 
menu.setLogo(R.drawable.ic_launcher); 
menu.setDisplayUseLogoEnabled(true); 
2

該操作欄使用清單文件中的android:logo屬性。然後使用setDisplayUseLogoEnabled()來設置它的動作條

+0

當我的應用程序的主題是「Theme.Light」和onCreate函數我寫getActionBar()。setDisplayUseLogoEnabled(true);應用程序崩潰。我對你瞭解嗎? – Anamnisis

+0

您的代碼是否與操作欄一起工作,沒有執行任何徽標相關設置? –

+0

如果我在主題中寫這個'