简体   繁体   English

Android:使用内置图标或下载图标包

[英]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? 我想知道是否应该使用内置版本的Google图标作为菜单项,还是应该下载图标包?

Here's the default XML for my menu. 这是菜单的默认XML。 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. 但是,如果我使用Material-Design-IconPack中的图标,则它看起来像这样。 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中存在的默认可绘制图标不会根据材质设计按比例放大。 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. 材质图标默认不支持Android sdk,相反,您可以使用appcompat-v7支持库,该库默认情况下几乎没有材质图标,如复制,粘贴,清除,搜索,返回,菜单图标。

To use appcompat-v7 icons in your xml 在XML中使用appcompat-v7图标

@drawable/abc_ic_menu_paste_mtrl_am_alpha 

Note: Only few icons are listed out in appcompat-v7 . Note: appcompat-v7仅列出了很少的图标。 You don't have any other options without using Material-Design-IconPack once if you want to use specific other icons. 如果要使用其他特定图标,则没有其他任何选择而不使用Material-Design-IconPack

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. 我建议您找到要使用的图标,如果使用Eclipse,则可以导航:右键单击项目->新建->其他-> Android图标集。 Don't forget to check "Action Bar Tab Icons" and you will be able to generate icons correctly scaled for actionbar. 不要忘记检查“动作栏选项卡图标”,您将能够生成正确缩放为动作栏的图标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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