Webview顶部的元素

时间:2014-04-18 11:09:49

标签: java android xml webview

我应该在WebView的顶部放置一个元素(AdMob),因此当WebView滚动时,adv(AdMob)不会停留在页面顶部,而是滚动页面。 可能吗? 如果没有,我该怎么做?

谢谢!

PS:我是意大利人,抱歉有任何错误:|

1 个答案:

答案 0 :(得分:1)

如果您将AdMob View和WebView分开并将它们放在父容器(如LinearLayout)中,然后将该布局放在ScrollView中,则可以执行此操作:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
          android:orientation="vertical"   
          android:layout_width="match_parent"
          android:layout_height="wrap_content">
          <com.google.ads.AdView android:id="@+id/adView"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 ads:adUnitId="MY_AD_UNIT_ID"
                 ads:adSize="BANNER"
                 ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
                 ads:loadAdOnCreate="true"/>
          <WebView
                android:id="@+id/webView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />
      </LinearLayout>
</ScrollView>