0

I'm currently having a problem with a seemingly simple layout. I have a static header (with logo and button), a WebView and then a static footer (with centre button). There seems to be a space between these 3 I cannot remove (I made the root background red so it's obvious where the space is).

Any idea how I can make the WebView fill this entire space so this red background is gone?

Also Eclipse is giving me the following warning for my RelativeLayout blocks:

This RelativeLayout layout or its LinearLayout parent is possibly useless; transfer the background attribute to the other view

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/commonlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FF0000"
    android:orientation="vertical"
    android:padding="0dp"
    android:weightSum="10" >

    <LinearLayout
        android:id="@+id/llheader"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <RelativeLayout
            android:id="@+id/relativeLayout1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:background="@drawable/bgx" >

            <Button
                android:id="@+id/Button_logout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="2dp"
                android:background="@drawable/ic_launcher" />

            <Button
                android:id="@+id/Button_playlist"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="2dp"
                android:background="@drawable/logo" />
        </RelativeLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/lldata"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="8"
        android:background="#00FF00" >

        <WebView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/webview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/llfooter"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_margin="0dp"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal"
        android:visibility="visible" >

        <RelativeLayout
            android:id="@+id/relativeLayout2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="@drawable/bgx" >

            <Button
                android:id="@+id/issue"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:background="@drawable/ic_launcher"
                android:textColor="#FFFFFF" />
        </RelativeLayout>
    </LinearLayout>

</LinearLayout>

enter image description here

4

1 回答 1

0

知道如何让 WebView 填满整个空间,这样红色背景就消失了吗?

您应该尝试在 webview 的布局中使用 weight 标记为 1。

或删除 webview 的布局父级并直接使用权重为 1 的 webview。

于 2012-07-11T16:46:47.330 回答