我是Android开发的新手.我只是按照基本的创作developer.android.com来创建我的第一个应用程序.
当我创建Action BAr时,我不得不将此搜索按钮添加到它.我创建了菜单xml,这就是我写的.
<!-- Search, should appear as action button -->
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:showAsAction="never" />
Run Code Online (Sandbox Code Playgroud)
现在我的问题是关于XML的这一部分
android:icon="@drawable/ic_action_search"
Run Code Online (Sandbox Code Playgroud)
我在eclipse中遇到编译错误,其中说,
错误:错误:找不到与给定名称匹配的资源(在'icon'处,值为'@ drawable/ic_action_search').
我检查了developer.android.com并且也搜索了它,但我无法找到解决方案.
我需要解决这个问题.和往常一样,我可以跳过XML的这一部分,我得到的只是纯文本"SEARCH",但图标肯定会更好看.
dtu*_*ene 42
如果您使用Eclipse,这是一种简单的方法:
Eclipse将使用新图标自动填充res/drawable-*目录,并缩放到目录大小.无需下载任何内容,了解PNG或将图标复制到多个目录中.
我使用文件向导A LOT.
guy*_*.gc 24
在Android工作室:
右键单击Drawable文件夹>选择新建>图像资源
(或者,点击shift,shift并输入'Image Asset')
在弹出的对话框中单击"确定"
从向导中,您可以自定义所需的资产.选择是通知图标,操作栏图标还是启动器图标.您可以从剪贴画中选择图标,从文本创建图标或从磁盘导入图像.该向导将负责为新图像创建不同的分辨率.

小智 7
正如其他人所建议的那样,你需要在正确的文件夹中放置(放置)图标图标"ic_action_pn",这是"/ res/drawable"你可能需要为一个或多个"drawable"移动一个图形文件"子文件夹"/ res"
您可以在(http://developer.android.com/design/downloads/index.html#action-bar-icon-pack)找到图标图形(以及您将来可能需要的其他图标).
请注意:请勿使用包装中的"核心图标/无样式".使用"All_Icons/holo_light"(最有可能)或"All_icons/holo_dark".
| 归档时间: |
|
| 查看次数: |
40778 次 |
| 最近记录: |