我有一个带有对话框主题的活动。
<activity
android:name=".MyActivity"
android:theme="@android:style/Theme.Dialog" />
该 Activity 使用以下 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)下方,Activity 填充了父级,我看到了完整的网站。
我试图动态创建 WebView。我试图在 onCreate() 中设置 LayoutParams。没有改变。我也尝试在 FrameLayout 和 WebView 上调用 invalidate() 但结果是一样的......