2012-08-07 28 views
1

我已經發布了一個應用程序,但問題在於admob推動佈局,比方說當您打開活動後開始繪製手勢,然後幾秒鐘後會彈出一個廣告,推動內容並因此破壞您繪製的手勢。Android - Admob推動佈局下降

我該如何阻止這種情況發生,我希望廣告加載但不推動它下面的內容。

我已經包括了我創建的姿態佈局

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

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/gridbg" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 

     android:orientation="horizontal"> 

    <com.google.ads.AdView 
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
     android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ads:adUnitId="" 
     ads:adSize="BANNER" 
     ads:loadAdOnCreate="true" 
     android:gravity="center_horizontal"/> 

    </LinearLayout> 

    <android.gesture.GestureOverlayView 
     android:id="@+id/gestures_overlay" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1.0" 
     android:gestureColor="#00FFFF" 
     android:gestureStrokeType="multiple" /> 

    <LinearLayout 
     style="@android:style/ButtonBar" 

     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 

     android:orientation="horizontal"> 

     <Button 
      android:id="@+id/done" 

      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 

      android:enabled="false" 

      android:onClick="addGesture" 
      android:text="@string/button_done" 

      style="@style/BlueButtonText" 
      android:background="@drawable/blue_button" 
      /> 

     <Button 
      android:layout_width="0dip" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 

      android:onClick="cancelGesture" 
      android:text="@string/button_discard" 

      style="@style/BlueButtonText" 
      android:background="@drawable/blue_button" 
      /> 

    </LinearLayout> 

</LinearLayout> 

回答

1

它推你的觀點,因爲你設置的高度WRAP_CONTENT的XML。首次加載視圖時,不會顯示任何廣告,因此高度爲零。嘗試將容器視圖的高度,認爲總是佔用你需要爲自己的廣告空間:

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="50dp" 
     android:orientation="horizontal"> 

    <com.google.ads.AdView 
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
     android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ads:adUnitId="" 
     ads:adSize="BANNER" 
     ads:loadAdOnCreate="true" 
     android:gravity="center_horizontal"/> 

</LinearLayout> 
+1

或者,他也可以完全擺脫LinearLayout,只需在com.google.ads.AdView中放置'layout_height =「50dp」'。 – 2012-08-07 21:22:33

+0

@EricLeichtenschlag非常真實。我通常喜歡在我的廣告背後拍一個背景,這樣他們就更加美味了,所以我的包裝通常都是包裝好的。 – 2012-08-07 21:36:12

+0

歡呼聲,工作很好在平板電腦和移動 – Reg 2012-08-08 20:14:47

0

,如果你不會得到一個廣告,你將結束與空的空間,這將是怪異並在小屏幕上浪費可觀的空間。

不僅如此,而且據我所知,廣告在不同屏幕上的尺寸應該是不同的。

我想你應該考慮做下一件事:

  1. 把廣告上的佈局

  2. 把它的頂部只,這不是重要的是,用戶將看到的地方。甚至可以在啓動畫面,轉換屏幕和設置頁面上使用動畫,以便在廣告顯示時以及完成時更改佈局。

+0

測試了一些非常好的點,但我認爲我會做的是,如果廣告不加載我把我自己的廣告鏈接到我的應用程序之一。 – Reg 2012-08-08 20:16:32

+0

是的,這也是一個不錯的主意。但是,如果在用戶嘗試點擊應用程序的自己的橫幅時顯示廣告,您會做什麼?對用戶來說不是很奇怪嗎? – 2012-08-08 20:59:14

+0

我會做的是改變它加載廣告的方式,在我剛剛使用XML的時刻,但要檢測廣告是否尚未加載,然後加載自己的橫幅廣告或從iad等其他網絡中加載廣告,我會必須在代碼中加載它。我不會有我的橫幅作爲默認我會加載它編程 – Reg 2012-08-10 23:58:39