简体   繁体   中英

Android: use built-in icons or download icon pack

I wonder if I should use the built in version of Google's icons for menu items or if I should download the icon pack instead?

Here's the default XML for my menu. It's using the built-in icons but the visual results looks a bit odd.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      tools:context=".ParkItemActivity">

    <item android:id="@+id/action_remove"
          android:title="@string/action_remove"
          app:showAsAction="ifRoom"
          android:icon="@android:drawable/ic_menu_delete" />

    <item android:id="@+id/action_save"
          android:title="@string/action_save"
          app:showAsAction="always"
          android:icon="@android:drawable/ic_menu_save" />
</menu>

使用内置图标的菜单

But if I use the icons from the Material-Design-IconPack, then it looks like this. But is there a recommended way? Remark: Can't find the trash-icon in the new icon-pack. And the delete/remove is a simple minus symbol.

  android:icon="@mipmap/ic_remove_white_48dp"
  android:icon="@mipmap/ic_save_white_48dp"

菜单使用官方图标包中的图标

Yes you are right, default drawable icons present in the android sdk doesn't scaled up according to the material design. Android sdk by default is not supported with material icons, instead of that you could make use of appcompat-v7 support library, which has few materials icon by default like copy, paste, clear, search, back, menu icons respectively.

To use appcompat-v7 icons in your xml

@drawable/abc_ic_menu_paste_mtrl_am_alpha 

Note: Only few icons are listed out in appcompat-v7 . You don't have any other options without using Material-Design-IconPack once if you want to use specific other icons.

I reccomend you to find icons you would like to use and if you use Eclipse, you can navigate: Right-click your project -> New -> Other -> Android Icon Set. Don't forget to check "Action Bar Tab Icons" and you will be able to generate icons correctly scaled for actionbar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM