【发布时间】:2016-07-08 21:26:50
【问题描述】:
我想更改 searchview 的默认搜索图标。 我尝试了以下方法:
int searchImgId = getResources().getIdentifier("android:id/search_mag_icon", null, null);
ImageView searchIconView = (ImageView) mSearchView.findViewById(searchImgId);
if(searchIconView != null){
searchIconView.setImageResource(R.drawable.ic_clear_white);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
searchIconView.setLayoutParams(layoutParams);
但它根本没有改变搜索图标,我该怎么做。我也检查了其他链接并尝试了给出的解决方案,但在我的情况下也不起作用。
How to change the default icon on the SearchView, to be use in the action bar on Android?
如果有人在这里有想法,请帮忙。
【问题讨论】:
标签: android searchview