Android icon vs logo
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 accompaniedby a label (see the android:label attribute).
This attribute must be set as a reference to a drawable resource containing theimage definition. If it is not set, the icon specified for the application as awhole is used instead (see the element's icon attribute).
Theactivity's icon — whether set here or by the element— is also the default icon for all the activity's intent filters (see the element's icon attribute).
大體意思就是說icon代表了一個activity,它作為activity的介面顯示展示給使用者,比如說啟動介面上MainActivity的表徵圖。此外,它的屬性值必須是一個drawable類型的資源檔。如果沒有給activity定義,那麼這個activity會使用application的icon屬性。
下面是application的icon屬性介紹:
android:icon
An iconfor the application as whole, and the default icon for each of theapplication's components. See the individual icon attributesfor , , , ,and elements.
This attribute must be set as a reference to a drawable resource containing the image (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 logofor 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。
Using a logo instead ofan icon
By default, the systemuses your application icon in the action bar, as specified by the icon attribute in the or element. However, if you also specifythe logo attribute, then the action bar usesthe logo image instead of the icon.
A logo should usually bewider than the icon, but should not include unnecessary text. You shouldgenerally 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.
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的布局。