简体   繁体   中英

Element at the top of a Webview

I should put an element (AdMob) at the top of a WebView, so when the WebView scrolls, the adv (AdMob) doesn't stay at the top of the page but scrolls with the page. Is it possible? If not, how can I do this?

Thanks!

PS: I'm Italian, sorry for any error :|

This can be done if you seprate the AdMob View and WebView and put them in a parent container such as a LinearLayout, and then place that layout in a 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM