我正在寻找访问 Assets 文件夹中文件的路径,我已经尝试过此代码,但没有获得文件的真实路径
File file = new File("file:///android_asset/fonts/NotoNaskhArabic-Regular.ttf");
String absolutePath = file.getAbsolutePath();
是否有“android_asset”引用 Assets 文件夹? 我如何获取文件路径?
最佳答案
您可以使用以下代码访问 Assets 文件夹下的自定义字体。
TextView myTextView = (TextView) findViewById(R.id.textView);
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/yourfont.ttf");
myTextView.setTypeface(typeface);
关于java - android中文件的访问路径作为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46284038/