2014-02-24 145 views
0

我在小屏幕上顯示AdMob橫幅時出現問題(橫向模式正在運行)。 在Galaxy S4上進行測試,會顯示廣告,但僅在橫向模式下顯示在小屏幕上。我已經嘗試將xml佈局參數(寬度和高度)更改爲match_parent,wrap_content和fill_parent,但仍然是同樣的事情。沒有足夠的空間來顯示AdMob橫幅(Android)

錯誤堆棧跟蹤: 02-24 16:30:36.327:W/Ads(396):沒有足夠的空間顯示廣告。需要320x50像素,但只有208x239像素。

我的XML是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@raw/backgroundc" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <Button 
     android:id="@+id/buttonGetLuck" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:background="@layout/get_luck_custom_button" 
     android:onClick="buttonGetLuck" 
     android:text="Get Lucky" 
     android:textStyle="italic" 
     android:typeface="sans" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="16dp" 
     android:text="See your luck for today." 
     android:textColor="#7CFC00" 
     android:textSize="18sp" 
     android:textStyle="italic" 
     android:typeface="serif" /> 

    <LinearLayout 
     android:id="@+id/bannerLayuout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal" 
     android:layout_centerHorizontal="true"/> 

</RelativeLayout> 

我的代碼是:

// Create the adView. 
    adView = new AdView(this); 
    adView.setAdUnitId("*******"); 
    adView.setAdSize(AdSize.BANNER); 

    // AdMob banner layout 
    LinearLayout layout = (LinearLayout)findViewById(R.id.bannerLayuout); 

    // Add the adView to it. 
    layout.addView(adView); 

    // Initiate a generic request. 
    AdRequest adRequest = new AdRequest.Builder().build(); 

    // Load the adView with the ad request. 
    adView.loadAd(adRequest); 
+0

使用片段... –

+0

我也testet與adSize時.SMART_BANNER但仍不起作用... – Balflear

+0

如果您看不到某個視圖,並且確定它應該在那裏。嘗試添加一個ScrollView到父視圖。這將允許您查看子View是否被推出屏幕。我認爲這就是你的佈局的問題現在 –

回答

1

我認爲這個問題可能是在父視圖 「填充」。

嘗試刪除這些行:

的android:paddingLeft = 「@捫/ activity_horizo​​ntal_margin」 的android:paddingRight = 「@捫/ activity_horizo​​ntal_margin」