3
我想在我的Android應用程序中使用自定義字體,TextView
中的自定義字體正常工作,但我找不到在WebView
中添加自定義(unicode)字體的方法,我儘可能地嘗試過,但失敗了,看看我的代碼,看看我是否錯過了一些東西。謝謝。!在WebView中爲我的Android應用程序使用自定義(unicode)字體
我在資產文件夾中創建了一個帶有自定義字體系列的CSS文件,並用LoadDataWithBaseURL
調用它,但它不起作用。
htmlTextView = (WebView) findViewById(R.id.htmlTextView);
String text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />";
htmlTextView.loadDataWithBaseURL("file:///android_asset/", text, "text/html", "UTF-8", null);
htmlTextView.getSettings().setJavaScriptEnabled(true);
htmlTextView.setBackgroundColor(Color.TRANSPARENT);
htmlTextView.getSettings().setDefaultFontSize(
WebHelper.getWebViewFontSize(this));
CSS文件:
@font-face {
font-family: 'iskoola pota';
src: url('fonts/iskpota.ttf') format('truetype');
}
我不想使用html文件,我只是想在我的wordpress基於android應用程序中使用自定義(unicode)字體。 – SNoV