FrameLayout/WebView会忽略对话框主题中的填充租金



我有一个对话框主题的"活动"。

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

该活动使用以下xml布局:

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

WebView的内容将从SD卡上存储的文件中加载(作为意向数据提供的内容)。这种情况发生在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);
}

项目详细信息:minSDK:7(2.1)

我的问题是,WebView和/或FrameLayout没有填充_parent。活动的高度与用于按钮的高度完全相同。我几乎看不懂这一页的第一行。我的问题只发生在蜂窝3.x上。下面(<=2.3)"活动"填充了家长,我看到了完整的网站。

我尝试动态创建WebView。我尝试在onCreate()中设置LayoutParams。一切都没有改变。我也试着在FrameLayout和WebView上调用invalidate(),但结果是一样的。。。

这个解决方案对我有效:

如何获得对话框样式的活动窗口来填充屏幕?

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.your_layout);
    getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}

尝试使用RelativeLayout作为FrameLayout,也许它会起作用。我不知道FrameLayout是否接受填充租金。

最新更新