Search code examples
androidwebviewinvalidationandroid-framelayoutfill-parent

FrameLayout/WebView ignores fill_parent in dialog theme


I have an Activity with the dialog theme.

<activity
    android:name=".MyActivity"
    android:theme="@android:style/Theme.Dialog" />

That Activity uses the following xml layout:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_article_frame_layout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000">
    <WebView
        android:id="@+id/activity_article_web_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
    <Button
    android:id="@+id/activity_article_close_button"
        android:layout_width="25dip"
        android:layout_height="26dip"
        android:layout_marginTop="5dip"
        android:layout_marginRight="5dip"
        android:layout_gravity="right|top"
        android:background="@drawable/close_button" />
</FrameLayout>

The content of the WebView will be loaded from a stored file on the sdcard (content provided as intent data). This happens in the onCreate():

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article);

    // Handle to the WebView
    mWebView = (WebView) findViewById(R.id.activity_article_web_view);
    initWebView();
    mWebView.loadDataWithBaseURL(null, myHtmlContent, "text/html", "utf-8", null);

    // Handle to the close button
    mCloseButton = (Button) findViewById(R.id.activity_article_close_button);
    mCloseButton.setOnClickListener(this);
}

Project details: minSDK: 7 (2.1)

My problem is, that the WebView and/or the FrameLayout doesn't fill_parent. The height of the activity is exactly the same height used for the button. I can barely read the first line of my page. My problem happens only on honeycomb 3.x. Below (<=2.3) the Activity fills the parent and I see the complete website.

I tried to create the WebView dynamically. I tried to set the LayoutParams in the onCreate(). Nothing changed. I also tried to call invalidate() on FrameLayout and WebView but the result is the same...


Solution

  • Try to use the RelativeLayout as FrameLayout, maybe it will work. I dont know if the FrameLayout accepts the fill_parent.