0

Android 用の基本的なブラウザーを作成する必要があります。WebView は、上部に戻るボタンのあるツールバー、下部にいくつかのボタンがあるツールバーです。

これを行うための最良の方法は何ですか?

これは私がこれまでに持っているものです:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/browserBackButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back" />

    <WebView
        android:id="@+id/webView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/backButton"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:src="@drawable/back" />

        <ImageButton
            android:id="@+id/forwardButton"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:src="@drawable/forward" />

        <ImageButton
            android:id="@+id/reloadButton"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:src="@drawable/reload" />

        <ImageButton
            android:id="@+id/browserButton"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:src="@drawable/safari" />
    </LinearLayout>

</LinearLayout>

ボタンの一番下の LinearLayout はまったく表示されません。上部の戻るボタンと WebView のみ。

4

2 に答える 2

1

LinearLayoutは問題ありません。

コントロールの高さを変更しWebView、重みを1に設定する必要があります

そうしてください:

<WebView android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent"

または、Lintツールで推奨されているように:

<WebView android:layout_height="0dip" android:layout_weight="1" android:layout_width="fill_parent"

重みは重要です。それはビューに残りのスペースを埋めるように強制します。

それでも問題が解決しない場合は、下部パネルの高さを一定の値に設定するか、画像ボタンの高さをwrap_contentに設定して、確実に機能するようにすることもできます。

于 2012-08-20T19:57:31.113 に答える
0

個人的には、ネストを行うのは好きではありませんLinearLayouts。レイアウトがより複雑になると、パフォーマンスが低下する可能性があります。小さなことでは大したことではないかもしれません。ただし、を使用することをお勧めしますRelativeLayouts

xmlns:android="http://schemas.android.com/apk/res/android"また、あなたの秒で負けますLinearLayout。あなたはそれを必要としません。

お役に立てれば。

于 2012-08-20T19:37:09.227 に答える