android - 如何在xamarin android中将自定义字体设置为searchview提示
问题描述
我在 xamarin android 中使用 searchview。我在 Assets->fonts 文件夹中有一个自定义字体。我需要将该字体应用于我的搜索视图提示。
我尝试如下:
字体类型 = Typeface.createFromAsset(getAssets(),"fonts/Kokila.ttf"); searchView.setTypeface(type);
但它不起作用。谁能告诉我如何将自定义字体应用于搜索视图提示。
谢谢
解决方案
您需要更改搜索视图内的 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;
快乐编码!
推荐阅读
- python - 在 for 循环中更新数据框
- angular - ngModel 的撤消更改不会反映视图中的结果
- php - API 设计 - 检索资源的端点 列名
- excel - 在 excel 表中,第二列数据应基于第一列进行验证。
- javascript - 未知提供者:membershipServiceProvider <- membersService <- angularjs 依赖注入中的membershipController 错误
- powershell - 使用 Set-AdfsRelyingPartyTrust PowerSell 命令从 ADFS 依赖方删除注释?
- angularjs - Angular js数据表使用
- c# - 组合迭代器
- rxjs - 在 RxJS 6 中,如果捕获到错误,我如何跳过流的 tap() 部分
- java - 在不同机器中嵌入 Redis