搜索视图边框颜色更改和搜索提示图标更改

时间:2014-01-22 12:49:31

标签: android searchview android-search

如何更改Android searchview边框颜色和searchview提示图标?

enter image description here

2 个答案:

答案 0 :(得分:2)

您必须使用反射来设置SearchView的样式。查看:http://novoda.com/blog/styling-actionbar-searchview

答案 1 :(得分:0)

MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
   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));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);