资产文件夹中字体的地址是什么 - android studio
what is the address of a font in assets folder - android studio
我的应用程序中有一个 webView,我需要从 assets 文件夹中的 .ttf 字体设置字体系列,这是我的 String 填充 webView :
String font_size = 24;
String font_family;
String main_txt = "<html>" + "<head></head>" + "<body dir='rtl' style='font-size: " +font_size+"px; 'font-family: "+font_family+";"+">" + "<text-align: justify;' >" + book.get("content").toString() + "</body>" + "</html>";
我的问题是如何在 font_family 变量中引用 .ttf 字体以更改 WebView 字体?
如果您将字体引用为 fonts/mytypeface.ttf
,它将适用于任何 assets/fonts/*
文件。
// Font must be placed in assets/fonts folder
@font-face {
font-family: spqr; src: url('fonts/spqr.ttf');
}
一个文件在app:\src\main\assest中的地址是"file:///android_asset/a.ttf"在android studio
我的应用程序中有一个 webView,我需要从 assets 文件夹中的 .ttf 字体设置字体系列,这是我的 String 填充 webView :
String font_size = 24;
String font_family;
String main_txt = "<html>" + "<head></head>" + "<body dir='rtl' style='font-size: " +font_size+"px; 'font-family: "+font_family+";"+">" + "<text-align: justify;' >" + book.get("content").toString() + "</body>" + "</html>";
我的问题是如何在 font_family 变量中引用 .ttf 字体以更改 WebView 字体?
如果您将字体引用为 fonts/mytypeface.ttf
,它将适用于任何 assets/fonts/*
文件。
// Font must be placed in assets/fonts folder
@font-face {
font-family: spqr; src: url('fonts/spqr.ttf');
}
一个文件在app:\src\main\assest中的地址是"file:///android_asset/a.ttf"在android studio