[英]Android Studio assets fonts folder
I am using Android Studio and I have the following code: 我正在使用Android Studio,并且具有以下代码:
Typeface customTypeface = Typeface.createFromAsset(getAssets(), "micra.ttf");
Which executes perfectly when my .ttf
file is under the assets folder. 当我的.ttf
文件位于Assets文件夹下时,它可以完美执行。 But when I make a folder assets/fonts
, move the .ttf
file to that folder and try the following code: 但是,当我制作文件夹assets/fonts
,请将.ttf
文件移动到该文件夹并尝试以下代码:
Typeface customTypeface = Typeface.createFromAsset(getAssets(), "fonts/micra.ttf");
The application crashes. 应用程序崩溃。
What is the problem here? 这里有什么问题? Should I replace the /
symbol with something else? 我应该用其他符号代替/
符号吗? My assets folder is under app/src/main. 我的资产文件夹位于app / src / main下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.