I want to create a dialog with a web browser containing a facebook login site.
I tried with PopupWindow - the keyboard did not appear after clicking on the text field.
Same thing with AlertDialog. Finally, I used the pure Dialog class and it βworksβ, but when I click on the text field, the entire web view flickers and turns transparent except for the text field.
I am attaching a screenshot with an alert box and a facebook login website after the focus of the text box. I tried with setting hardware acceleration or another background, but without any effects. Is there any other way to display facebook popup in webview?
Thanks for any help! Code:
Dialog dialog = new Dialog(MyActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.webview_popup); dialog.setCanceledOnTouchOutside(true); dialog.setCancelable(true); WebView popupWebview = (WebView)dialog.findViewById(R.id.webViewFromPopup); popupWebview.loadUrl(url); dialog.show();
XML:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/popupWindow" android:background="#000" android:minHeight="600dp"> <WebView android:id="@+id/webViewFromPopup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layerType="software" android:layout_weight="0.8" android:background="#FFFFFFFF" /> </LinearLayout>
DECISION:
I create a dialogue programmatically - this is a solution to the problem ... somehow.
Code:
private Dialog webViewPopup; private void showWebViewPopup(final String url) { Dialog dialog = new Dialog(MyActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.webview_popup); dialog.setCancelable(true); WebView popupWebview = new WebView(MyActivity.this); LayoutParams params = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 0.99f); popupWebview.setLayoutParams(params); Button cancelButton = new Button(MyActivity.this); LayoutParams bParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 0.01f); cancelButton.setLayoutParams(bParams); cancelButton.setText("Cancel"); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { webViewPopup.dismiss(); } }); LinearLayout popupLayout = (LinearLayout) dialog.findViewById(R.id.popupWindow); popupLayout.addView(popupWebview); popupLayout.addView(cancelButton); dialog.show(); popupWebview.loadUrl(url); webViewPopup = dialog; }
XML: (webview_popup.xml file)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/popupWindow" android:minHeight="600dp" > </LinearLayout>
Piotr source share