How can I change the font of Search view suggestion?

ぐ巨炮叔叔 提交于 2019-12-13 05:51:19

问题


I searched for hours all they suggest is using customized cursor adapter. however I'm using content provider to fill the suggestion and don't have any cursor adapter . I'm able to find AutoCompleteTextView and change the font of the editable text view now, but I want to do the same for the suggestions. What should I do?


回答1:


You would get a handle to the textview from the sdk and then change it since they don't expose it publicly.

Try this code:

int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);
Typeface type = Typeface.createFromAsset(getAssets(),"fonts/Kokila.ttf"); 
textView.setTypeface(type);



回答2:


To change the font of text you have to implement your own CursorAdapter and in bindView() method get the reference to the TextView and apply the font using TextView.setTypeface().



来源:https://stackoverflow.com/questions/30915523/how-can-i-change-the-font-of-search-view-suggestion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!