2

私はTabHostのすぐ下にAdViewを取得しようとしています。 RelativeLayoutはandroid:layout_alignParentBottom="true"でこれを可能にしていますが、これはTabHostの内容と重なり、ScrollViewの場合は各タブ内に追加します(これは高さが十分に大きいビューで発生します)XMLのTabHostの下にAdViewを追加する

今すぐ画面上の別々のスペースにTabHostとAdViewを持つことに、以下のコードを使用しています。これは、直接の上に、のTabHostを持つことができます。

<?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> 

答えて

4

あなたは今、タブホストがadview後に残りのスペースを取る

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

ようadview後に残りのスペースを埋めるために、タブのホストをしなければなりません。

+0

ありがとうございました!これは私がこれを行い、xmlのtabhostの下にadviewを置くとすぐに機能しました:) – skyllo

関連する問題