当前位置: 首页 > 工具软件 > blade-icons > 使用案例 >

Adaptive icons

龚国源
2023-12-01

Adaptive icons support a variety of visual effects.

Android 8.0 (API level 26) introduces adaptive launcher icons, which can display a variety of shapes across different device models. 

 

Creating adaptive icons in XML

define res/xml/shortcuts.xml

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:enabled="true"
        android:icon="@drawable/ic_add_contact_shortcut"
        android:shortcutId="shortcut-add-contact"
        android:shortcutShortLabel="@string/shortcut_add_contact">
        <intent
            android:action="android.intent.action.INSERT"
            android:data="content://com.android.contacts/contacts"
            android:targetPackage="com.android.contacts"
            android:targetClass="com.android.contacts.activities.ContactEditorActivity"/>
    </shortcut>
</shortcuts>

 

create alternative drawable resources in your app for use with Android 8.0 (API level 26) in res/mipmap-v26/

eg: res/drawable-anydpi-v26/ic_add_contact_shortcut.xml only support for v26

<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@color/ic_launcher_color"/>
    <foreground android:drawable="@drawable/ic_launcher_app"/>
</adaptive-icon>

 

 类似资料:

相关阅读

相关文章

相关问答