我正在尝试使用WebView实现RichTextEditor。
我使用以下代码插入图像。它工作得很好。
webview.loadUrl("javascript:
(function () { document.execCommand('insertImage', 'false','"
+ selectedImagePath +"');})()");
要指定高度和宽度,我使用以下命令,但它不起作用。
String imagSpec = " width=" + 200 + " height=" + 200 + " border= 5" ;
webview.loadUrl("javascript(function () {
document.execCommand('insertImage', 'false','"
+ selectedImagePath +imagSpec+ "');})()");
以下代码为我工作。
String exeSucess="document.execCommand('insertHtml', false,'<img +
src="http://www.developphp.com/images/home_over.png" +
height=200 width=auto style="object-fit=contain;"></img>');";
我没有调用'insertImage'命令,而是使用'insertHtml'命令,在光标位置插入图像标签。
谢谢