【发布时间】:2016-07-02 11:27:38
【问题描述】:
我为 Android 编写了一个 Cordova 插件。
这是一个简单的初始化函数,用于恢复 mu 问题
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
...
}
}
请注意,当记录FrameLayout.LayoutParams.MATCH_PARENT 时,它会显示-1。
默认 WebView 布局是否在 Cordova 中使用 MATCH_PARENT 设置?
如何使用/heigh 检索 WebView 或 WebView 的父级?
【问题讨论】:
标签: android cordova webview cordova-plugins