在xamarin for android中更改字体的错误

3 c# android xamarin.android typeface xamarin

我想更改textview的字体,然后按照教程和示例中给出的代码进行操作.但我收到了错误.我的代码是

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

错误说我在第二行收到错误

非静态字段方法需要对象refrance

我想在textview中使用kruti dev 10字体.

Vik*_*ana 7

更改

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/k010.ttf");
Run Code Online (Sandbox Code Playgroud)

Typeface tf = Typeface.CreateFromAsset (Application.Context.Assets, "fonts/k010.ttf");
Run Code Online (Sandbox Code Playgroud)

  • 谢谢vikas这就是我要找的东西. (2认同)