2014-02-13 2 views
0

<p>으로 시작하여 </p> 태그로 끝나는 웹보기에 일부 내용을 표시하고 있습니다. 나는 loadDataWithBaseURL하여 웹보기에 내용을로드하고 중간에 내용을 표시하려고 :가운데에서 내용을 Webview에 정렬하는 방법

public static String contentPrefix = "<html><head><style type='text/css'>#content_wrapper {position: relative; margin: 0px auto;} </style></head><div id='content_wrapper'>"; 
public static String contentPostfix = "</div></html>"; 
webView.loadDataWithBaseURL("", contentPrefix + result + contentPostfix, "text/html", "UTF-8", ""); 

을하지만 그것은 작동하지 않습니다. 중간에 내용을 표시하려면 어떻게해야합니까?

답변

2

마지막으로 작동!

String desiredContent = "my test html"; 
    String strBody = "<html>" 
     + "<head>" 
     + "  <style type=\"text/css\">" 
     + "  @font-face " 
     + "   { font-family: Tahoma;" 
     + "    src:url(\"~/android_asset/fonts/MyriadPro-Regular.otf\") " 
     + "   }" 
     + "  #text" 
     + "   { font-family: Tahoma;" 
     + "    font-size:14;" 
     + "    text-align: center;" 
     + "   }" 
     + "  </style>" 
     + "" 
     + "</head>" 
     + "<body dir=\"rtl\" id=\"text\">" 
     + desiredContent 
     + " </body></html> "; 

myWebView.loadDataWithBaseURL(null, strBody, "text/html", "utf-8", 
     null); 
0

시도 :

public static String contentPrefix = "<html><head><style type=\"text/css\">p{text-align:center;}</head>"; 
관련 문제