在 Google 商店中使用我的应用程序 2 周后,我意识到横幅没有在真实设备中显示。当我用 Android Studio 虚拟设备测试它时,它很好。
这是与我的 MainActivity 中的横幅相关的代码:
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
mAdView.loadAd(request);
和布局:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_background">
<com.flaviofaria.kenburnsview.KenBurnsView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_marginTop="?attr/actionBarSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="misc.songbox.Search"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/bannerAd">
</com.google.android.gms.ads.AdView>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:dividerHeight="0dp"
/>
</LinearLayout>
</RelativeLayout>
最佳答案
使用此 xml 代码...
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/bannerAd">
</com.google.android.gms.ads.AdView>
关于android - Admob 横幅未在真实设备中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44102226/