HTML标签< DIV>字符串的WebView [英] html tag <div> in string webview

查看:287
本文介绍了HTML标签< DIV>字符串的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有活动包括长的TextView 必须分开由水平的彩色线(分)多个段落,我用的WebView允许添加的:

I have activity consist of long textview must be separated as multiple paragraphs by horizontal colored line (divider) , i used webview to allow adding of:

 <div html tag 

我在Google上搜寻这片code的形成彩色横向分隔线后发现的,但是当我把它应用到网络上查看它doesont如下工作:

i found after googling that this piece of code forming a colored horizontal line divider , but when i applied it to web view it doesont work as below:

<div class="aligncenter" style="width:400px;height:0;border-top:2px solid #FF7500;font-size:0;"></div>

我应用为下面的WebView,但它不工作:

i applied as below to webview but it doesnt work :

公共类WebViewActivity延伸活动{

public class WebViewActivity extends Activity {

private WebView webView;
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);

    webView = (WebView) findViewById(R.id.webView1);

    String customHtml = "<body><h1>Heading Text</h1><p>This is example  " +
                        "<strong>HTML </strong>tag in webviw .&nbsp;</p>" +   
                        "<div class="aligncenter" style="width:400px;height:0;
                           border-top:2px solid #FF7500;font-size:0;"></div>" ;

           webView.loadData(customHtml, "text/html", "UTF-8");}

也尝试如下不工作:

also try it as follow not working :

    String customHtml = "<body><h1>Heading Text</h1><p>This is example  " +
                        "<strong>HTML </strong>tag in webviw .&nbsp;</p>" +   
                        "<div class=aligncenter style=width:400px;height:0;border-
                         top:2px solid #FF7500;font-size:0;></div>" ;

           webView.loadData(customHtml, "text/html", "UTF-8");}
                                              }            

任何意见,如何在网页视图中添加的div HTML标记的将是AP preciated,谢谢。

Any advice how to adding of div html tag in webview will be appreciated , thanks.

推荐答案

尝试使用参数='值',而不是参数=值的字符串内。

Try using param = 'value' instead of param = "value" inside the string.

这样的:

String customHtml = "<body><h1>Heading Text</h1><p>This is example  " +
                        "<strong>HTML </strong>tag in webviw .&nbsp;</p>" +   
                        "<div class='aligncenter' style='width:400px;height:0;
                           border-top:2px solid #FF7500;font-size:0;'></div>" ;

顺便说一句做ü有地方在 CSS 设置 aligncenter 类?

这篇关于HTML标签&lt; DIV&GT;字符串的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆