應用多個icon的對比

來源:互聯網
上載者:User

  在給應用設計表徵圖的時候,可能會遇到這樣的需求,應用表徵圖有老版和新版兩種,而又想在案頭上同時顯示這兩個表徵圖以對比效果。    一個應用本身只有一個自己的icon,在AndroidManifest.xml檔案中的<application>的android:icon屬性中可以進行設定。不過Android系統本身Intent的shortcut屬性可以將啟動一個intent的方式儲存到Android系統的案頭上,並且還可以設定相應的圖片。中將好友“添加到案頭”的功能應該就是用shortcut的intent來實現的。這裡藉助於shortcut intent來實現多個應用icon的對比。具體代碼如下 一、設定shortcut intent的代碼 複製代碼    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        Intent shortcutIntent=new Intent(MainActivity.this,MainActivity.this.getClass());                final Intent icon1=new Intent();        icon1.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);        icon1.putExtra(Intent.EXTRA_SHORTCUT_NAME, "原表徵圖");        icon1.putExtra(Intent.EXTRA_SHORTCUT_ICON,BitmapFactory.decodeResource(getResources(), R.drawable.icon1));        icon1.setAction("com.android.launcher.action.INSTALL_SHORTCUT");        sendBroadcast(icon1);                final Intent icon2=new Intent();        icon2.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);        icon2.putExtra(Intent.EXTRA_SHORTCUT_NAME, "新表徵圖");        icon2.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.icon2));        icon2.setAction("com.android.launcher.action.INSTALL_SHORTCUT");        sendBroadcast(icon2);    }複製代碼二、AndroidManifest.xml檔案中增加相應許可權     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/> 三、用5.0和5.2的表徵圖進行對比後的結果,可以看出5.2的表徵圖要更扁平化並且顯得更暗一些。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.