Xamarin.如何将自定义字体设置为searchView在Xamarin Android中的提示



我正在使用Xamarin Android中的搜索视图。我在资产 ->字体文件夹中具有自定义字体。我需要将该字体应用于我的搜索提示。

我尝试了下面的尝试:

typeface type = typeface.createfromasset(getAssets()," fonts/kokila.ttf");searchView.setTypeface(type);

但它不起作用。任何人都可以告诉我如何将自定义字体应用于搜索View提示。

谢谢

您需要更改搜索视图中的文本视图字体。

使用该代码访问文本视图:

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;

快乐的代码!

最新更新