Android 如何在 Actionbar 中设置 SearchView 的样式?
我需要更改 ActionBar
中 SearchView
的样式。特别是,如果可能的话,我需要更改文本提示颜色和 SearchView
图标。我如何在 XML 中实现这一点(在 XML 中是否可能)?
如果这是不可能的,我如何使用自定义视图轻松地重新创建类似的行为? SearchView
的关闭/展开行为对我来说特别有用。
I need to change the style of my SearchView
in my ActionBar
. In particular I need to change the text hint color and the SearchView
icons if possible. How can I accomplish this in XML (is it even possible in XML)?
If this isn't possible, how can I easily recreate similar behavior with a custom view? The close/expand behavior of the SearchView
is particularly useful for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否尝试过类似的操作(使用 ActionBarSherlock):
它对我来说效果很好。
Have you tried something like this (With ActionBarSherlock):
It works fine for me.
看起来您可能需要为您的搜索操作提供自定义布局。我还没有找到任何有关修改默认 SearchView 的文档。但这确实允许关闭/展开行为。
http://developer.android.com/guide/topics/ui/ actionbar.html#ActionView
相关问题:
It looks like you may need to supply a custom layout for your search action. I haven't been able to find any documents that talk about modifying the default SearchView. But this does allow the close/expand behavior.
http://developer.android.com/guide/topics/ui/actionbar.html#ActionView
Related questions:
您需要创建一个新主题并在清单文件中使用它。
这对我来说效果很好。
You need to create a new theme and use it in manifest file.
It worked fine for me.
正确的答案是使用您自己的自定义样式来重载操作栏小部件样式。对于带有深色操作栏的全息光,请将其放入您自己的样式文件中,例如
res/values/styles_mytheme.xml
:确保您的应用程序使用主题自定义主题,如 在此处输入链接描述
The right answer is to overload the action bar widget style with your own custom style. For holo light with dark action bar, put this in your own styles file such as
res/values/styles_mytheme.xml
:Make sure your application is using theme custom theme as described in enter link description here