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);
使用片段... –
我也testet与adSize时.SMART_BANNER但仍不起作用... – Balflear
如果您看不到某个视图,并且确定它应该在那里。尝试添加一个ScrollView到父视图。这将允许您查看子View是否被推出屏幕。我认为这就是你的布局的问题现在 –