ダイアログテーマのアクティビティがあります。
<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) のアクティビティが親を満たし、完全な Web サイトが表示されます。
WebView を動的に作成しようとしました。onCreate() で LayoutParams を設定しようとしました。何も変わっていません。また、FrameLayout と WebView で invalidate() を呼び出そうとしましたが、結果は同じです...