Adding AdView under TabHost in XML

I am trying to get the AdView directly under TabHost. RelativeLayout allows this to happen with android:layout_alignParentBottom="true" , however it overrides the contents of the TabHost and does it for the ScrollView, which I add inside each tab (this will probably happen for any views that were tall enough)

Currently, the closest I can get TabHost and AdView in my own separate space on the screen using this code (below), which allows me to have Ad directly above TabHost ... so close, any ideas?

  <? xml version = "1.0" encoding = "utf-8"?>
 <LinearLayout
         xmlns: android = "http://schemas.android.com/apk/res/android"
     xmlns: ads = "http://schemas.android.com/apk/lib/com.google.ads"
     android: layout_width = "fill_parent"
     android: layout_height = "fill_parent"
     android: orientation = "vertical">

     <com.google.ads.AdView
         android: id = "@ + id / ad"
         android: layout_width = "fill_parent"
         android: layout_height = "wrap_content"
         ads: adSize = "BANNER"
         ads: adUnitId = "####"
         ads: loadAdOnCreate = "true"
         ads: testDevices = "####" />

     <TabHost
         android: id = "@ android: id / tabhost"
         android: layout_width = "fill_parent"
         android: layout_height = "wrap_content">

         <LinearLayout
             android: layout_width = "fill_parent"
             android: layout_height = "fill_parent"
             android: orientation = "vertical">

             <TabWidget
                 android: id = "@ android: id / tabs"
                 android: layout_width = "fill_parent"
                 android: layout_height = "wrap_content" />

             <FrameLayout
                 android: id = "@ android: id / tabcontent"
                 android: layout_width = "fill_parent"
                 android: layout_height = "fill_parent" />
         </LinearLayout>
     </TabHost>

 </LinearLayout>

+2
android android-layout android-tabhost admob android-linearlayout
source share
1 answer

You have to make the tab host fill in the remaining space after viewing, for example

 <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1.0"> 

Now the tab host will take up the remaining space after the announcement.

+4
source share

All Articles