2010-12-20 18 views
0

我有以下的東西在我的XML文件奠定了:製作網頁視圖FILL_PARENT留底圖像以上的Android

  1. 網頁視圖
  2. 底部圖像/ AdMob廣告

因爲我希望我的AdMob來顯示在底部,我爲建議的Admob選擇了兩種不同的佈局LinearLayout,爲其他視圖選擇了RelativeLayout。另外,由於我先顯示splashscreen,然後是webview,我的邏輯是這樣的,我希望他們都在framelayout中。我的底部形象和Admob一個在另一個之上。 所以,我的代碼都爲:

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:myapp="http://schemas.android.com/apk/res/app.news" 
android:layout_width="wrap_content" 
android:layout_height="fill_parent"> 

<FrameLayout 
android:id="@+id/views" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<ImageView 
     android:id="@+id/splash_screen" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:scaleType="center" 
      android:src="@drawable/splash_screen" 
      android:visibility="visible" 
    /> 

<WebView 
android:id="@+id/webvw" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:gravity="fill_vertical" 
android:scrollbars="none" 
android:visibility="invisible" 
/> 

      <ImageView 
     android:id="@+id/bottomImage" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:scaleType="fitEnd" 
      android:src="@drawable/logo" 
      android:visibility="visible" 
    /> 

</FrameLayout> 

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_alignParentBottom="true" 
android:gravity="bottom" 
android:layout_alignBottom="@id/views" 
> 

<com.admob.android.ads.AdView 
android:id="@+id/ad" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
myapp:backgroundColor="#000000" 
myapp:primaryTextColor="#FFFFFF" 
myapp:secondaryTextColor="#CCCCCC" 
myapp:testing="false" 
/> 
</LinearLayout> 

</RelativeLayout> 

我想要的WebView佔據所有空間,除了底部的形象,我不知道如何做到這一點的WebView使用高度爲「FILL_PARENT」。

任何人都可以請幫忙嗎?

Thanx提前。

回答

1

嘗試使用零高度並設置重力至1:

android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
+0

設置web視圖高度0dip正在使網頁視圖不會出現/可見。 – neha 2010-12-20 10:18:20

+0

但你也需要使用LinearLayout和orientation =「vertical」。首先,孩子是WebView(或包含它的任何嵌套佈局),其中layout_height =「0」和layout_weight =「1」。第二個孩子是AdMob,其layout_height =「wrap_content」 – Olegas 2011-01-13 08:37:02

相關問題