简体   繁体   English

无法在Webview Android上显示粗体文本

[英]Can not show bold text on Webview Android

I have a html file with css file. 我有一个带CSS文件的HTML文件。 I want to load it into Webview. 我想将其加载到Webview中。 In the css file, i set font-weight for some elements in html file. 在css文件中,我为html文件中的某些元素设置了font-weight。 But the problem is the webview cannot show the bold text that i set. 但是问题是Webview无法显示我设置的粗体文本。 In the list devices i tested: Nexus S, Nexus 4, Nexus 5, Nexus 7, Samsung S3, LG, only Nexus 7 can display the bold text. 在我测试过的设备列表中:Nexus S,Nexus 4,Nexus 5,Nexus 7,三星S3,LG,只有Nexus 7可以显示粗体文本。

I research many times but still no result. 我研究了很多次,但仍然没有结果。 Do you have any ideas for this. 您对此有任何想法吗? Thanks you. 谢谢。

Here is my html file: 这是我的html文件:

    <link href="css/style.css" rel="stylesheet" type="text/css">
<title></title>
</head>
<body>

<section id="answer_box"><!--解答ボックス-->
    <p class="explain_title">正解</p>
    <p class="answer_p"><span class="answer_no">イ</span>  </p>

</section>
<section class="question_title_box">
    <p class="question_main_title"><span class="question_no">1</span>リスニングテスト(放送による指示に従って答えなさい。)</p>
</section><!--question_title_box終わり-->

Here is my css file 这是我的css文件

p.question_title_box{
        font-size: 15px;

        font-weight: 600
    }

Here is how i load html file: 这是我加载HTML文件的方式:

wvQuestion = (WebView) findViewById(R.id.question_content);
WebSettings webSettings = wvQuestion.getSettings();
webSettings.setJavaScriptEnabled(true);
String url = "test.html";
wvQuestion.loadUrl(url);

assuming that your css file is stored in assets/css , you should be able to load it through loadDataWithBaseURL . 假设您的CSS文件存储在assets/css ,则应该能够通过loadDataWithBaseURL加载它。 Eg 例如

wvQuestion.loadDataWithBaseURL("file:///android_asset/css/", url, "text/html", "UTF-8", null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM