mic*_*oan 4 android xamarin.android xamarin
我理解如何将.tff文件添加到我的项目中,但是我无法找到一个帖子,清楚地说明一旦添加了字体后如何以及在何处实现该字体.我找到了一个帖子,说要实现这样的字体:
var typeface = Typeface.CreateFromAsset(context.Assets,fileName);
但我不知道应该在哪里添加这行代码,或者我应该使用什么来代替上下文.有人可以给我一个基本的解释,所以我知道我错过了什么?
Sus*_*ver 11
使用模板创建Xamarin.Android单个Activity应用程序:
使用以下构建类型向Assets目录添加字体AndroidAsset:
??? Assets
? ??? AboutAssets.txt
? ??? Jellee-Roman.ttf
Run Code Online (Sandbox Code Playgroud)
在OnCreate添加以下内容:
Button button = FindViewById<Button>(Resource.Id.myButton);
// Add these two lines:
var font = Typeface.CreateFromAsset(Assets, "Jellee-Roman.ttf");
button.Typeface = font;
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
Run Code Online (Sandbox Code Playgroud)