如何更改SearchView默认图标? [英] How to change SearchView default icon?

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

问题描述

我使用了" Android操作栏样式生成器"来生成自己的全息的主题. 然后,我在操作栏中添加了两个图标,一个图标用于searchFilter,一个图标用于文件选择器,两个图标均为白色.文件选择器图标(在右侧)看起来不错,但是搜索图标看起来是深灰色的.在搜索文本视图上键入时,关闭按钮也会显示为深灰色.

I've used "Android Action Bar Style Generator" in order to generate my own Holo theme. Then I've added two icons to the action bar, one for a searchFilter and one for a file picker, both icons are white. File picker icon (at the right) looks good, but somehow search icon looks dark grey. When typing on the search text view, close button also looks dark grey.

我尝试更改操作栏的颜色,也尝试从searchview更改颜色,但均未成功.搜索视图为什么显示这种颜色?我该如何更改?

I've tried changing color of the actionbar and also from the searchview, without success. Why is the search view showing this color? How can I change it?

非常感谢您.

更新:我以为我的应用正在使用我的图标,但没有使用,它使用默认的搜索视图图标,所以我的问题实际上是,如何更改广告的默认图标搜索视图? menu.xml文件中的这句话不起作用:

UPDATE: I thought that my app was using my icon but it doesn't, it uses the default search view icon, so my question actually is, how do I change the default icon of the search view? This sentence at the menu.xml file is not working:

android:icon="@drawable/selectable_header_search"

推荐答案

不幸的是,由于主题属性searchViewSearchIcon不是公开的,因此没有简单的方法将SearchView图标更改为自定义可绘制对象.有关详细信息,请参见答案.

Unfortunately, there is no easy way to change the SearchView icon to a custom drawable, since the theme attribute searchViewSearchIcon is not public. See this answer for details.

但是,我认为您的问题是由错误主题的继承引起的.请使用android:Theme.Holo.Light.DarkActionBar作为主题的基础.然后,操作栏上的默认图标应为浅色.

However, I think that your problem is caused by inheriting from the wrong theme. Please use android:Theme.Holo.Light.DarkActionBar as the base for your theme. Then the default icons on the action bar should have a light color.

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    ...
</style> 

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

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