【问题标题】:How can I change the font of Search view suggestion?如何更改搜索视图建议的字体?
【发布时间】:2015-06-18 12:36:13
【问题描述】:

我搜索了几个小时,他们建议使用自定义光标适配器。但是我正在使用内容提供者来填写建议并且没有任何光标适配器。我现在可以找到 AutoCompleteTextView 并更改可编辑文本视图的字体,但我想对建议做同样的事情。我该怎么办?

【问题讨论】:

标签: android searchview


【解决方案1】:

您可以从 sdk 获得 textview 的句柄,然后更改它,因为他们不会公开它。

试试这个代码:

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】:

    要更改文本字体,您必须实现自己的CursorAdapter,并在bindView() 方法中获取对TextView 的引用并使用TextView.setTypeface() 应用字体。

    【讨论】:

      猜你喜欢
      • 2018-04-05
      • 1970-01-01
      • 2015-03-30
      • 2013-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      相关资源
      最近更新 更多