私はあなたが何を意味するか知っていると思います。これが私のクイックハックです。ChildBrowser.java を変更する必要があります。コードに入る前に、これが基本的に閉じるボタンを ChildBrowser の webview に移動することを説明させてください。しかし、それは右上にホバリングしていません。したがって、ChildBrowser を下にスクロールすると、ボタンが移動します。
また、進む、戻る、アドレス URL テキストフィールドなどの他のボタンも削除しました。これは、ShowWebPage 関数専用です。
public String showWebPage(final String url, JSONObject options) {
// Determine if we should hide the location bar.
if (options != null) {
showLocationBar = options.optBoolean("showLocationBar", true);
}
// Create dialog in new thread
Runnable runnable = new Runnable() {
/**
* Convert our DIP units to Pixels
*
* @return int
*/
private int dpToPixels(int dipValue) {
int value = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP,
(float) dipValue,
cordova.getActivity().getResources().getDisplayMetrics()
);
return value;
}
public void run() {
// Let's create the main dialog
dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialog) {
try {
JSONObject obj = new JSONObject();
obj.put("type", CLOSE_EVENT);
sendUpdate(obj, false);
} catch (JSONException e) {
Log.d(LOG_TAG, "Should never happen");
}
}
});
// Main container layout
LinearLayout main = new LinearLayout(cordova.getActivity());
main.setOrientation(LinearLayout.VERTICAL);
// Toolbar layout
RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44)));
toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
toolbar.setHorizontalGravity(Gravity.LEFT);
toolbar.setVerticalGravity(Gravity.TOP);
toolbar.setBackgroundColor(Color.TRANSPARENT);
// Close button
ImageButton close = new ImageButton(cordova.getActivity());
RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
close.setLayoutParams(closeLayoutParams);
close.setId(5);
try {
close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png"));
} catch (IOException e) {
Log.e(LOG_TAG, e.getMessage(), e);
}
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
closeDialog();
}
});
// WebView
webview = new WebView(cordova.getActivity());
webview.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
webview.setWebChromeClient(new WebChromeClient());
WebViewClient client = new ChildBrowserClient(edittext);
webview.setWebViewClient(client);
WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setBuiltInZoomControls(true);
settings.setPluginsEnabled(true);
settings.setDomStorageEnabled(true);
webview.loadUrl(url);
webview.setId(6);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.requestFocus();
webview.requestFocusFromTouch();
toolbar.addView(close);
// Don't add the toolbar if its been disabled
if (getShowLocationBar()) {
webview.addView(toolbar);
}
// Add our webview to our main view/layout
main.addView(webview);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.FILL_PARENT;
dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
}
private Bitmap loadDrawable(String filename) throws java.io.IOException {
InputStream input = cordova.getActivity().getAssets().open(filename);
return BitmapFactory.decodeStream(input);
}
};
this.cordova.getActivity().runOnUiThread(runnable);
return "";
}