我试图用自定义的字体在Android的工作室,因为我们在Eclipse一样。但遗憾的是无法弄清楚哪里放了资产文件夹!
I was trying to use custom font in Android Studio as we did in Eclipse. But unfortunately could not figure out where to put the 'assets' folder!
下面是几个步骤来解决它:
Here is the few steps to solve it:
转到(项目文件夹) 和应用程序>来源>主 创建文件夹的资产>字体到主要文件夹。把你的'abc.ttf到字体文件夹。 Go to the (project folder) Then app>src>main Create folder 'assets>fonts' into the main folder.
Put your 'abc.ttf' into the fonts folder.
AssetManager am = context.getApplicationContext().getAssets();
typeface = Typeface.createFromAsset(am,
String.format(Locale.US, "fonts/%s", "abc.ttf"));
setTypeface(typeface);
或尝试这种方式:
or try this way:
TextView tx = (TextView)findViewById(R.id.textview1);
Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/abc.ttf");
tx.setTypeface(custom_font);
上一篇:Plotly:如何手动设置 plotly express 散点图中点的颜色?图中、颜色、Plotly、plotly
下一篇:Android 4.3的蓝牙BLE不叫onCharacteristicRead()蓝牙、不叫、Android、BLE