我一直在尝试将自定义字体设置到android.support.v7.widget.SearchView
的查询提示和视图中输入的文本。我尝试从资源中动态设置字体到searchView,创建一个TypeFace对象,但问题在于"SearchView不包含setTypeface(Typeface tf)方法。" 我尝试了一个自定义SearchView类,但找不到合适的。
private void setFont(String font1, String font2, String font3)
{
Typeface tf = null;
tf = UiUtil.changeFont(MainActivity.this, font1);
btn1.setTypeface(tf);
tf = UiUtil.changeFont(MainActivity.this, font2);
btn2.setTypeface(tf);
tf = UiUtil.changeFont(MainActivity.this, font3);
btn3.setTypeface(tf);
tf = UiUtil.changeFont(MainActivity.this, font3);
// no set typeface method..
}
searchView.setQueryHint(Html.fromHtml("<font face = tf>" + getResources().getString(R.string.search_hint) + "</font>"));
- Apurva