2012-02-20 4 views
1

tabhost의 모든 탭에 Google 광고 adview을 얻으려고 시도 중이지만 작동하지 않습니다. main.xml에 adview를 배치하면 모든 탭에서 adview를 볼 수 있습니다. 하지만 문제는보기 (버튼)가 광고 뷰 위에 표시되어 더 이상 광고를 볼 수 없다는 것입니다.모든 탭 (탭 호스트, admob)에 adview

는 main.xml에 :

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

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

     <TabHost 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@android:id/tabhost" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

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

        <include layout="@layout/tab1" /> 

        <include layout="@layout/tab2" /> 

        <include layout="@layout/tab3" /> 

        <include layout="@layout/tab4" /> 
       </FrameLayout> 
      </LinearLayout> 
     </TabHost> 
    </TableLayout> 
</LinearLayout> 

tab1.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res/com.this.app" 
    android:id="@+id/tab1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     ads:adSize="BANNER" 
     ads:adUnitId="xxx" /> 

    <ScrollView 
     android:id="@+id/scrollview1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/adView" > 

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

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

       <TableRow> 

        <Button 
         android:id="@+id/button1" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="1" /> 

        <Button 
         android:id="@+id/button2" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="2" /> 
       </TableRow> 
      </TableLayout> 
     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 
+0

는 (화면 하단) –

+0

@Shahzad 탭 아래 광고의 위치를 ​​지정 아래 또는 tabs.Please 위의 광고를보고 싶어요. – Bldjef

답변

0

이 layout.It 항상 프레임 layout.Hope 아래에 시도 할 수 있습니다 도움이됩니다. U을

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#fff" > 

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

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_above="@+id/tv" 
      android:layout_below="@android:id/tabs" > 
     </FrameLayout> 

     <TextView 
      android:id="@+id/tv" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:text="Ads" /> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignLeft="@android:id/tabcontent" 
      android:layout_alignParentTop="true" 
      android:paddingTop="-10dip" > 
     </TabWidget> 
    </RelativeLayout> 

</TabHost> 
+0

흠,하지만 스크롤 및 기타 레이아웃에 대한 단추에 대한 scrollview가 필요합니다. 그렇지 않으면 작동하지 않을 것이다. – Bldjef

+0

질문을 명확하게하십시오. 어떤 유형의 레이아웃이 필요합니까 ??????? –