【问题标题】:How to set custom font to searchview hint in xamarin android如何在xamarin android中将自定义字体设置为searchview提示
【发布时间】:2019-07-22 19:48:31
【问题描述】:
我在 xamarin android 中使用 searchview。我在 Assets->fonts 文件夹中有一个自定义字体。
我需要将该字体应用到我的搜索视图提示中。
我尝试如下:
字体类型 = Typeface.createFromAsset(getAssets(),"fonts/Kokila.ttf");
searchView.setTypeface(type);
但它不起作用。谁能告诉我如何将自定义字体应用于搜索视图提示。
谢谢
【问题讨论】:
标签:
android
xamarin.android
【解决方案1】:
您需要更改搜索视图内的 textview 字体。
使用该代码访问文本视图:
LinearLayout linearLayout1 = (LinearLayout)SearchView.GetChildAt(0);
LinearLayout linearLayout2 = (LinearLayout)linearLayout1.GetChildAt(2);
LinearLayout linearLayout3 = (LinearLayout)linearLayout2.GetChildAt(1);
AutoCompleteTextView textView = (AutoCompleteTextView)linearLayout3.GetChildAt(0);
textView.Typeface = YourCustomTypeface;
编码愉快!