2015-12-16 27 views
2

工作這是我形式 -風格是不是在Android的WebView中

<form name="clmbLead" id="clmbLead_{{FROM_ID}}" method="POST"> 
    <input type="hidden" id="lineItem_{{FROM_ID}}"> 
    <input type="hidden" id="ItemId_{{FROM_ID}}"> 
    <div class="form_div"> <a href="javascript:void(0)" class="closeBtn" onclick="closeLeadfrm('{{FROM_ID}}')">x</a> <div class="form" id="form_{{FROM_ID}}"> 
    <p>Submit your details in the form below:</p> 
    <div class="fild"><label for="name" >Name</label> 
    <input type="text" name="name" id="name_{{FROM_ID}}" placeholder="Name" onKeyPress="removeError(this.id)"> 
    </div> 
    <div class="fild"><label for="mobile" >Mobile No.</label> 
    <input type="text" name="mobile" id="mobile_{{FROM_ID}}" maxlength="10" placeholder="Mobile No."onKeyPress="removeError(this.id)" > 
    </div> 
    <div class="fild"><label for="email" >Email ID</label> 
    <input style="width:261px" type="text" name="email" id="email_{{FROM_ID}}" placeholder="Email ID" onKeyPress="removeError(this.id)"> 
    </div> 
    <br clear="all"> 
    <div style="text-align:center"> 
    <button class="submit_1" onclick="return 

    ReadLeads('{{FROM_ID}}')">Submit</button> 
    </div> 
    </div> 
    <div class="thanku-msg" id="thanku-msg_{{FROM_ID}}" style="display: none;">Thanks for sharing your Details!<br>We shall get back to you soon 
    </div> 
    </div> 
    </form> 

form被正確加載在webview。但是,如果我添加以下的form上述風格這是行不通的 -

<style> 
.main_div {position: absolute; width: 100%;top: 0; left: 0; height: 100%;z-index: 9; margin-top:10px;overflow:hidden; } 
.main_div .required { border-color:red !important; } 
.main_div .form_div { background-color: #f5f5f5;border: 1px #dddddd solid;font: normal 14px arial; min-height: 250px;max-width: 500px;max-height: 250px;} 
.main_div .form_div .form {width:92%;float: left;padding:10px 4%;} 
.main_div .form_div .form .fild {width:50%;float: left;} 
.formobile .form_div .form .fild {width:100%;} 
.main_div .form_div .form .fild label {width: 100%;display: block;padding-bottom:3px;} 
.formobile .form_div .form .fild label {display:none;} 
.main_div .form_div .form .fild input {width:90%;padding:10px 0;margin-bottom:10px;padding-left:8px;border-radius:1px;border:1px #c1c1c1 solid;} 
.formobile .form_div .form .fild input {width:100%;margin-bottom:15px;} 
.main_div .form_div .form p {padding:0;margin:0;padding-bottom:10px;margin-bottom:10px;border-bottom:1px #dcdcdc solid;} 
.formobile .form_div .form {padding-top:60px;padding-bottom: 20px;} 
.formobile .form_div .form p {position: absolute;width:100%;left:0;top:0;padding: 10px 0;background-color:#EAEAEA;} 
.formobile .form_div .form p::before {margin-left:10px;content: ""} 
.main_div .form_div .form button.submit_1{padding:10px 30px;background-color:#e52b02;border:none;border-radius:5px;color: #FFFFFF;font:normal 15px arial;cursor: pointer;} .main_div .form_div .closeBtn {text-decoration: none;font: bold 20px arial;color: #000;right: 0;padding: 5px 10px;} .formobile .form_div .closeBtn {background-color:#EAEAEA;background-color: #DDDDDD;padding: 7px 15px;border-left:1px #D3D3D3 solid;} 
.main_div .form_div .thanku-msg {position: absolute;margin:auto;left:0;right:0;top:0;bottom:0;width: 250px;height: 50px;text-align: center;} 
.callLdForm {width: 81px; font: normal 11px arial; text-decoration: none; color: #353535; text-align: center; display: block; padding: 2px 0;background-color: rgba(0,0,0,0.2); border: 1px #A9A6A6 solid;border-radius: 3px;} 
</style> 
<div class="main_div" id="Lead_Frm_{{FROM_ID}}"> 

我試圖把這種風格在CSS文件,並補充說,CSS文件。但是這也沒有奏效。 請建議如何使這種風格工作。

的WebView代碼(我試着與內容和文件兩種方式) -

browser = new WebView(this); 
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 
setContentView(browser,lp); 
browser.getSettings().setJavaScriptEnabled(true); 
browser.addJavascriptInterface(new abcInterface(this), "abc"); 

//put as content 
browser.loadData(content, "text/html", "UTF-8"); 

//or put as html file 
browser.loadUrl("file:///storage/emulated/0/dummy6.html"); 
+0

你的android webview代碼? –

+0

添加了webview代碼。請立即檢查。 – ADattatrey

+0

你有試過瀏覽器嗎?這個HTML文件完全適用於瀏覽器? –

回答

1

CSS /風格正在採取太多的時間來加載。

ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 
setContentView(browser,lp); 

而且他們是在stylebody沒有寬度和高度參數,所以這個代碼設置網頁視圖寬度和高度爲0和加載的數據變得不可見。

設置固定的寬度和高度layoutparam,它變得可見。