Android WebView 布局占据剩余空间

5
我希望创建一个看似简单的布局,但是我在其中遇到了一些问题。该布局包括一个标题、一个 Web 视图的正文部分以及底部横幅,如附图所示。
我需要 Web 视图占据标题和底部横幅之间所有剩余的空间。
我已经尝试过以下方法:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:background="@drawable/back"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <ImageView  
android:id="@+id/banner"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content" 
     android:src="@drawable/banner" /> 
<WebView  
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bck"
    android:layout_weight="2"
    android:layout_gravity="center"/>
  <RelativeLayout   
     android:layout_width="wrap_content"   
     android:layout_height="wrap_content"
     android:layout_weight="4"> 
        <com.mobclix.android.sdk.MobclixMMABannerXLAdView 
                android:id="@+id/banner_adview"
                android:layout_width="320dip"
                android:layout_height="50dip"
                android:layout_gravity="center"
                android:layout_alignParentBottom="true" />
   </RelativeLayout>

2个回答

4
把它们全部放在RelativeLayout中,在webview中使用layout_below="@id/header_banner"和layout_above="@+id/footer_banner"。

1

这个对你会有用:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/ddd"
    android:orientation="vertical" >
     <ImageView  
     android:id="@+id/banner1"
     android:layout_height="wrap_content"
     android:layout_width="fill_parent" 
     android:src="@drawable/atm" /> 
    <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" 
    />
    <ImageView  
     android:id="@+id/banner2"
     android:layout_height="wrap_content"
     android:layout_width="fill_parent"
     android:layout_weight="0" 
     android:src="@drawable/atm" /> 
</LinearLayout>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接