Android用Cordovaプラグインを作成します。ここでCordova Androidでwebviewの幅と高さを取得する方法は?
はFrameLayout.LayoutParams.MATCH_PARENT
をログインしたとき、それは-1
が表示されることを
public class MyPlugin extends CordovaPlugin {
CordovaWebView _webView;
ViewGroup _root;
public void initialize(CordovaInterface cordova, final CordovaWebView webView) {
super.initialize(cordova, webView);
_webView = webView;
_root = (ViewGroup) _webView.getView().getParent();
Log.d(TAG, Integer.toString(root.getLayoutParams().width)); // -1
Log.d(TAG, Integer.toString(webView.getView().getLayoutParams().width)); //-1 too
}
public boolean execute(final String action, final CordovaArgs args, final CallbackContext _callbackContext) throws JSONException {
Log.d(TAG, Integer.toString(_root.getLayoutParams().width)); // -1
Log.d(TAG, Integer.toString(_webView.getView().getLayoutParams().width)); // -1
...
}
}
注ミューproblemeを再開し、簡単な初期化関数です。 デフォルトのWebViewレイアウトがCordovaのMATCH_PARENTで設定されていますか?
どのようにWebViewまたはWebViewの親を/ heighで取得できましたか?
Thxを、しかしCordovaWebViewにonPageFinishedそのような方法は存在しません。 – dagatsoin
webview.setWebviewClient();を使用して、コードワWebviewのwebviewクライアントを設定できますか。 – Karacken