avast / android-styled-dialogs

Backport of Material dialogs with easy-to-use API based on DialogFragment
Apache License 2.0
2.15k stars 450 forks source link

Custom Dialog and WebView Issue #31

Closed nitinmishra27 closed 10 years ago

nitinmishra27 commented 10 years ago

I have this custom dialog implementation

public static String TAG = "MainContainerDialogHelpers"; static String dialog_title, contentUrl_to_load; public static void show(SherlockFragmentActivity activity, String title, String contentURL) { dialog_title = title; contentUrl_to_load = contentURL; //contentURL is html file from assests in this form "file:///android_asset/help_documentation.html" new MainContainerDialogHelpers().show(activity.getSupportFragmentManager(), TAG); } @Override public BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) { builder.setTitle(dialog_title); LayoutInflater layoutInflater = LayoutInflater.from(getActivity()); View v = layoutInflater.inflate(R.layout.about_it_ebooks, null);

    WebView webview = (WebView)v.findViewById(R.id.about_it_ebooks_wv);

    webview.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            return true;
        }
    });

    webview.setLongClickable(false);
    webview.loadUrl(contentUrl_to_load);
            //contentUrl_to_load is html file from assests in this form "file:///android_asset/help_documentation.html"

    builder.setView(v);
    builder.setPositiveButton("Dismiss", new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISimpleDialogListener listener = getDialogListener();
            if (listener != null) {
                listener.onPositiveButtonClicked(0);
            }
            dismiss();
        }
    });
    return builder;
}

and this is my layout

<?xml version="1.0" encoding="utf-8"?> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/about_it_ebooks_wv" android:layout_width="fill_parent" android:layout_height="fill_parent" />

The problem is when dialog builds it gives IMAGE1 (webview is not expanded) image1 potrait

When i change the orientation to horizontal it gives IMAGE2(Webview is now expanded) image2 horizontal

Again When i change the orientation to potrait it gives me IMAGE3(Webview is expanded by default) image3 potrait again

So i want to know if i'm doing some wrong thing or it's an issue known to you Guys.

nitinmishra27 commented 10 years ago

I fixed the issue by placing my webView in a ScrollView like this

<?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" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <WebView
            android:id="@+id/about_it_ebooks_wv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>
</ScrollView>

anyways, you should find a way, to do this.