gpt4 book ai didi

android - 样式在 android webview 中不起作用

转载 作者:太空狗 更新时间:2023-10-29 14:03:30 27 4
gpt4 key购买 nike

这是我的表单 -

    <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 它不起作用 -

<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");

最佳答案

css/style 加载时间过长。

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

并且它们在stylebody 中没有宽度和高度参数,所以这段代码将webview 宽度和高度设置为0,加载的数据变得不可见。

设置固定宽度和高度layoutparam,它变得可见。

关于android - 样式在 android webview 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34305061/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com