我不会去太多的细节,因为有一个很好的张贴在这里:here在适应searchview和为什么上述答案不起作用。
如果你想改变你的“X”,下面的工作来改变颜色
int crossId = searchView.getContext().getResources().getIdentifier("android:id/search_close_btn", null, null); // Getting the 'search_plate' LinearLayout.
ImageView image = (ImageView) searchView.findViewById(crossId);
Drawable d = image.getDrawable();
d.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
如果你想改变图标
int crossId = searchView.getContext().getResources().getIdentifier("android:id/search_close_btn", null, null); // Getting the 'search_plate' LinearLayout.
ImageView image = (ImageView) searchView.findViewById(crossId);
image.setImageResource(R.drawable.NEW_ICON_HERE);
如果您绘制图标所在?它在你的可绘制文件夹中吗? – GrIsHu
是它在可绘制的文件夹中 – jason
查看我的答案。 @jason – GrIsHu