Android如何在Actionbar中设置SearchView的样式?

gal*_*ite 6 android android-actionbar

我需要改变我的风格SearchView,我ActionBar.特别是我需要更改文本提示颜色和SearchView图标(如果可能).如何在XML中实现这一点(甚至可以在XML中实现)?

如果无法做到这一点,如何使用自定义视图轻松重新创建类似的行为?这种关闭/扩展行为SearchView对我来说特别有用.

Tob*_*ich 7

你尝试过这样的事情(使用ActionBarSherlock):

AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchText.setHintTextColor(getResources().getColor(R.color.white));
searchText.setTextColor(getResources().getColor(R.color.white));
Run Code Online (Sandbox Code Playgroud)

这对我来说可以.


pfo*_*han 1

看起来您可能需要为您的搜索操作提供自定义布局。我还没有找到任何有关修改默认 SearchView 的文档。但这确实允许关闭/展开行为。

http://developer.android.com/guide/topics/ui/actionbar.html#ActionView

相关问题: