2013-10-23 193 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

如果我在主题中写这个'