2013-05-05 102 views
1

將自定義字體設置爲HTML頁面並使用loadDataWithBaseURL加載HTML數據時,粗體標記被忽略。我的代碼是如下:Webview加載標籤問題loadDataWithBaseURL

webView.loadDataWithBaseURL("", "<html><style type=\"text/css\"> @font-face { font-family:\"customFont\"; src:url('file:///android_asset/fonts/customfont.ttf');line-height:45px;font-size:34px;} body { font-family:'customFont'; }</style><body><b>The legend is back!!</b></body></html>", "text/html", "utf-8", ""); 

我的如下所示的輸出:

當如下所示相同的內容使用loadData加載:

webView.loadData("", "<html><style type=\"text/css\"> @font-face { font-family:\"customFont\"; src:url('file:///android_asset/fonts/customfont.ttf');line-height:45px;font-size:34px;} body { font-family:'customFont'; }</style><body><b>The legend is back!!</b></body></html>", "text/html", "utf-8", ""); 

我的輸出是如下所示:

enter image description here

不確定可能出現的問題。是否有任何具體原因相同。

+0

你有沒有解決這個問題。即使我有同樣的問題。 – amsiddh 2013-06-27 07:14:22

+0

嘗試使用loadUrl方法,仍然是同樣的問題。 – amsiddh 2013-06-27 11:33:22

回答

2

現在我通過使用粗體字體和使用css在我的html中指定相同的方法來解決此問題。我的css代碼如下:

@font-face {font-family: MyArialBold;src: url('file:///android_asset/fonts/ArialBold.ttf')} b{font-family: ArialFontBold;}. 

希望有所幫助。