0

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+ "');})()");

正しく行うのを手伝ってください。

4

1 に答える 1

0

次のコードは私のために働いた。

  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」を使用してカーソル位置に画像タグを挿入しました。

ありがとう

于 2013-06-14T10:24:29.123 に答える