简体   繁体   中英

Webview with facebook login flickering in Dialog


I want to make a dialog with webview containing facebook login site.
I tried with PopupWindow - keyboard wasn't showing after clicking on textfield.
The same with AlertDialog. Finally I used pure Dialog class and it's "working", but when I am clicking on textfield whole webview is flickering and turns into transparent besides textfield.
I am attaching screenshot with alert box and facebook login website after textfield focus.

I tried with setting hardware accelerating or different background but without any effects. Is there other way to display facebook login 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>

在此输入图像描述 SOLUTION:


I am building dialog programmatically - it's solving problem... somehow.
Code:

    /* webview popup */
    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>

Since the input of the fields is giving you trouble, one work around would be to capture that data in your own form and process it upon reaching the webview.

Set it up so that your edittext view and keyboard popup when a user selects the field in webview.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM