如何更改 SearchView 上的默认图标,以在 Android 的操作栏中使用? [英] How to change the default icon on the SearchView, to be use in the action bar on Android?

查看:27
本文介绍了如何更改 SearchView 上的默认图标,以在 Android 的操作栏中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在自定义 SearchView 中的搜索图标时遇到了一些麻烦.在我看来,图标可以在 Item 属性中更改,对吗?只需检查下面的代码..

I'm having a bit of trouble customizing the search icon in the SearchView. On my point of view, the icon can be changed in the Item attributes, right? Just check the code bellow..

谁能告诉我我做错了什么?

Can someone tell me what I'm doing wrong?

这是我使用的菜单,带有我的自定义搜索图标 icn_lupa.但是当我运行应用程序时,我总是得到默认的搜索图标...

This is the menu I'm using, with my custom search icon icn_lupa. But when I run the app, I always get the default search icon...

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_search"
      android:title="@string/menu_search"
      android:icon="@drawable/icn_lupa"
      android:showAsAction="always"
      android:actionViewClass="android.widget.SearchView" />
</menu>

提前致谢.

推荐答案

看起来 actionViewClass 覆盖了图标,而且看起来你不能从 这个类.

It looks like the actionViewClass overides the icon and it doesn't look like you can change it from this class.

您有两个解决方案:

这篇关于如何更改 SearchView 上的默认图标,以在 Android 的操作栏中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆