FrameLayout / WebView忽略对话框主题中的fill_parent

|| 我有一个带有对话框主题的活动。
<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的内容将从sdcard上存储的文件中加载(内容作为意图数据提供)。这发生在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没有fill_parent。活动的高度与按钮使用的高度完全相同。我几乎看不到页面的第一行。我的问题只发生在蜂窝3.x。在(<= 2.3)下,活动填充了父级,我看到了完整的网站。 我试图动态创建WebView。我试图在onCreate()中设置LayoutParams。没有改变。我也尝试在FrameLayout和WebView上调用invalidate(),但结果是相同的...     
已邀请:
尝试将RelativeLayout用作FrameLayout,也许会起作用。 我不知道FrameLayout是否接受fill_parent。     
这个解决方案为我工作: 如何获得对话框样式活动窗口来填充屏幕?
    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.your_layout);

    getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}
    

要回复问题请先登录注册