2013-12-24 118 views
0

我似乎無法讓我的廣告顯示在最底部。它出現在我的xml佈局的最後一個按鈕之後。我已經嘗試了從新佈局到重量的所有內容,並且它不適用於我。如果你能幫上忙,那會很棒!在佈局底部設置adMob廣告

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

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

     <Button 
      android:id="@+id/reason_1" 
      android:layout_width="fill_parent" 
      android:layout_height="75dp" 
      android:background="@drawable/button" 
      android:text="@string/reason_1" /> 

     <Button 
      android:id="@+id/reason_2" 
      android:layout_width="fill_parent" 
      android:layout_height="75dp" 
      android:background="@drawable/button" 
      android:text="@string/reason_2" /> 

     <Button 
      android:id="@+id/reason_3" 
      android:layout_width="fill_parent" 
      android:layout_height="75dp" 
      android:background="@drawable/button" 
      android:text="@string/reason_3" /> 

     <Button 
      android:id="@+id/reason_button" 
      android:layout_width="fill_parent" 
      android:layout_height="75dp" 
      android:background="@drawable/button_layout" 
      android:drawableLeft="@drawable/ic_credit_cards" 
      android:drawableRight="@drawable/ic_credit_cards" 
      android:text="@string/reason_button_string" /> 

     <com.google.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5dp" 
      ads:adSize="BANNER" 
      ads:adUnitId="xxxxxx" 
      ads:loadAdOnCreate="true" > 
     </com.google.ads.AdView> 
    </LinearLayout> 

</ScrollView> 

回答

1

想法是使用RelativeLayout並將廣告放置在底部。然後將Scrollview放在它上面,這樣廣告總是位於屏幕的底部。不要使用fill_parent,它已被棄用。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_marginTop="5dp" 
    ads:adSize="BANNER" 
    ads:adUnitId="xxxxxx" 
    ads:loadAdOnCreate="true" > 
</com.google.ads.AdView> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@id/adView" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <Button 
     android:id="@+id/reason_1" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button" 
     android:text="@string/reason_1" /> 

    <Button 
     android:id="@+id/reason_2" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button" 
     android:text="@string/reason_2" /> 

    <Button 
     android:id="@+id/reason_3" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button" 
     android:text="@string/reason_3" /> 

    <Button 
     android:id="@+id/reason_button" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button_layout" 
     android:drawableLeft="@drawable/ic_credit_cards" 
     android:drawableRight="@drawable/ic_credit_cards" 
     android:text="@string/reason_button_string" /> 
    </LinearLayout> 
</ScrollView> 

</RelativeLayout> 
0

@svenoaks解決了我的答案3/4的方式。只好微調它。這是restuls。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_marginTop="5dp" 
    ads:adSize="BANNER" 
    ads:adUnitId="xxxxxx" 
    ads:loadAdOnCreate="true" > 
</com.google.ads.AdView> 



    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <Button 
     android:id="@+id/reason_1" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button" 
     android:text="@string/reason_1" /> 

    <Button 
     android:id="@+id/reason_2" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button" 
     android:text="@string/reason_2" /> 

    <Button 
     android:id="@+id/reason_3" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button" 
     android:text="@string/reason_3" /> 

    <Button 
     android:id="@+id/reason_button" 
     android:layout_width="match_parent" 
     android:layout_height="75dp" 
     android:background="@drawable/button_layout" 
     android:drawableLeft="@drawable/ic_credit_cards" 
     android:drawableRight="@drawable/ic_credit_cards" 
     android:text="@string/reason_button_text" /> 
    </LinearLayout> 

</RelativeLayout>