2010-08-26 6 views
2

J'ai un XML android et j'essaie d'obtenir les annonces à afficher au bas d'une tabview, mais ils ne se présentent pas. Je pense qu'il me manque juste quelque chose de très simple, mais je regarde cela depuis trop longtemps et j'espère que quelqu'un pourra m'aider. Voici le XML:Mise en page tabview Android avec Admob

<?xml version="1.0" encoding="utf-8"?> 

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:myapp="http://schemas.android.com/apk/res/com.Vdrop" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp"> 
     <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" 
      android:padding="5dp" /> 
      <com.admob.android.ads.AdView  
      android:id="@+id/ad" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="bottom" 
      myapp:backgroundColor="#000000" 
      myapp:primaryTextColor="#FFFFFF" 
      myapp:secondaryTextColor="#CCCCCC" 
    /> 
    </LinearLayout> 
</TabHost> 

Des pensées?

Répondre

2

OK, je l'ai compris. Vous devez essentiellement utiliser une mise en page relative pour placer une annonce en bas de l'écran, j'en ai donc fait une après la mise en page linéaire. Voici le XML:

<?xml version="1.0" encoding="utf-8"?> 

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:myapp="http://schemas.android.com/apk/res/com.Vdrop" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp"> 
     <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" 
      android:padding="5dp" /> 
    </LinearLayout> 
    <RelativeLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
    <com.admob.android.ads.AdView  
      android:id="@+id/ad" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      myapp:backgroundColor="#000000" 
      myapp:primaryTextColor="#FFFFFF" 
      myapp:secondaryTextColor="#CCCCCC" 
    /> 
    </RelativeLayout> 
</TabHost> 
0

Vous pouvez également utiliser avec dans LinearLayout. Aussi, vous faites attention au poids de la mise en page. Voici le XML;

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:myapp="http://schemas.android.com/apk/res/app.tabsample" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1"> 
     <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" 
      android:padding="1dp"/> 
    </LinearLayout> 
    <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" > 

     <com.admob.android.ads.AdView 
    android:id="@+id/ad" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    myapp:backgroundColor="#c6360a" 
    myapp:primaryTextColor="#FFFFFF" 
    myapp:secondaryTextColor="#CCCCCC"/> 

    </LinearLayout> 
</TabHost> 
0

Cela fonctionne vraiment bien!

<RelativeLayout 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="fill_parent" 
     android:layout_height="fill_parent"> 

<TabHost 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:layout_above="@+id/adView"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp"> 
     <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" 
      android:padding="5dp" /> 
    </LinearLayout> 

</TabHost>  


    <com.google.ads.AdView android:id="@+id/adView" 
         android:layout_width="wrap_content" 
      android:layout_alignParentBottom="true" 
         android:layout_height="wrap_content" 
         ads:adUnitId="AD_UNITID" 
         ads:adSize="BANNER" 
         ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" 
         ads:loadAdOnCreate="true"/> 


</RelativeLayout>