【发布时间】:2014-03-06 21:16:51
【问题描述】:
我的 Android 应用程序具有以下布局,但未显示广告。 在 logcat 中,我有关于“W/Ads:没有足够的空间来显示广告。需要 640x100,但只有 0x1038”的错误。
我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="top" />
</ViewPager>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxx"/>
</LinearLayout>
我如何在 Oncreate 中加载广告:
adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("xxxxxxx") //gnex
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
有什么想法吗?
【问题讨论】:
标签: android android-layout admob