views:

280

answers:

2

I declared a WebView activity in the manifest like this:

<activity android:name=".MyWebView"
    android:label="@string/app_name"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.Dialog">
</activity>

The WebView looks like this:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
    <WebView android:id="@+id/webview"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
    />
</LinearLayout>

When I start this activity within my main activity, only the title of the dialog, containing the apps name, is visible but not the WebView. If I add a TextView to the LinearLayout, it is shown as well, but still the WebView is missing. If I don't apply android:theme="@android:style/Theme.Dialog" in the manifest, the WebView is displayed.

Why is that and how can I show a WebView in a dialog?

A: 

I would think what you are doing would work. Maybe try to override the dialog class instead of the activity class.

schwiz
I don't get it to work, either way. Could you give a working example?
Manuel
+1  A: 

I found that it works if you change the webview to wrap_content rather than fill_parent. No idea why. It's probably a bug.

brybam
Nice, works for me. :) It takes while until the WebView is shown (so, there's only the title at first) but maybe I will add an infinite progress while the website is being loaded.
Manuel