标签:
Android 配置文件中有icon和logo两个属性。那这两个属性有什么区别呢?
清单文件中activity的icon属性介绍:
android:icon An icon representing the activity. The icon is displayed to users when a representation of the activity is required on-screen. For example, icons for activities that initiate tasks are displayed in the launcher window. The icon is often accompanied by a label (see the android:label attribute). This attribute must be set as a reference to a drawable resource containing the image definition. If it is not set, the icon specified for the application as a whole is used instead (see the <application>element's icon attribute). Theactivity's icon — whether set here or by the <application> element— is also the default icon for all the activity's intent filters (see the <intent-filter> element's icon attribute).
大体意思就是说icon代表了一个activity,它作为activity的界面显示展示给用户,比如说启动界面上MainActivity的图标。此外,它的属性值必须是一个drawable类型的资源文件。如果没有给activity定义,那么这个activity会使用application的icon属性。
下面是application的icon属性介绍:
android:icon An icon for the application as whole, and the default icon for each of the application's components. See the individual icon attributesfor <activity>, <activity-alias>, <service>, <receiver>,and <provider>elements. This attribute must be set as a reference to a drawable resource containing theimage (for example"@drawable/icon").There is no default icon.
同activity的icon属性类似,但是application的icon属性石没有默认值的。aplication的icon属性是用来显示在安装界面和安装包缩略图的,而不包括桌面和启动器图标。桌面、启动器上显示的图是应用的主activity(一般名称为MainActivity)里icon。
logo属性介绍:
android:logo A logo for the application as whole, and the default logo for activities. This attribute must be set as a reference to a drawableresource containing the image (for example"@drawable/logo"). There is no default logo.
logo不会被作为桌面图标,仅作为activity的导航图,而当同时设置了icon与logo属性时(闲的),logo会完全覆盖掉icon。
<span style="font-weight: normal;">Using a logo instead of an icon By default, the system uses your application icon in the action bar, as specified by the icon attribute in the<application> or <activity> element. However, if you also specifythe logo attribute, then the action bar usesthe logo image instead of the icon. A logo should usually be wider than the icon, but should not include unnecessary text. You should generally use a logo only when it represents your brand in a traditional format that users recognize. A good example is the YouTube app's logo—the logorepresents the expected user brand, whereas the app's icon is a modifiedversion that conforms to the square requirement for the launcher icon.</span>
ActionBar的应用:
ActionBar actionBar=getActionBar();
使用android:logo属性。不像方方正正的icon,logo的图像不会有任何宽度限制
当你有Logo的时候,你可以隐藏label。隐藏Label标签:
actionBar.setDisplayShowTitleEnabled(false);
隐藏logo和icon:
actionBar.setDisplayShowHomeEnabled(false);
默认情况下,actionBar放在你的activity的顶部,且作为activity布局的一部分。设置成为覆盖模式后,actionBar相当于漂浮在activity之上,不干预activity的布局。
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.main); }
参考:
http://stackoverflow.com/questions/6735649/android-icon-vs-logo
http://tieba.baidu.com/p/3516704970
http://blog.csdn.net/jdsjlzx/article/details/41353029
标签:
原文地址:http://blog.csdn.net/worst_hacker/article/details/45652621