c# - 在 xamarin for android 中更改字体时出错

标签 c# android xamarin.android xamarin typeface

我想更改我的 TextView 的字体,我遵循教程和示例中给出的代码。但是我在其中遇到错误。 我的代码是

var txt = FindViewById<TextView> (Resource.Id.textView1);
        Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/k010.ttf");
        txt.SetTypeface (tf, TypefaceStyle.Normal);

我在第二行收到错误消息

The object refrance is required for non static field,method

我想在我的 TextView 中使用 kruti dev 10 字体。

最佳答案

改变

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/k010.ttf");

Typeface tf = Typeface.CreateFromAsset (Application.Context.Assets, "fonts/k010.ttf");

关于c# - 在 xamarin for android 中更改字体时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20437882/

相关文章:

c# - 验证 Java Card 签名

android - 如何动态刷新ListView?

android - 如何在 Xamarin 中获取 ActivityManager 的实例?

xamarin - 如何处理 libmonosgen-2.0.so 崩溃?

xamarin.forms - 如何以Xamarin形式获取设备ID?

c# - 在枚举中使用按位或

javascript - 更好的 JavaScript/Typescript 调试器可视化工具

c# - 无法使用 DotNetZip 1.9 从 HttpInputStream 读取 zip 文件

java - 如何使用AsyncTask更新全局变量

android - 使用 gradle 进行 Android 仪器测试的命令行参数