AdMob Banner ad in my Activity
を統合しています。レイアウトはGridView
とAdView
で構成されています。AdMobバナーが表示されるときのレイアウトを調整する
は、私が欲しいもの: -広告が表示されていない
、すなわち開始時または広告をダウンロード、または何かなっているが、私はGridView
は、すべての画面を持っていると思います。しかし、広告を表示するには、必要なスペースをカバーする必要がありますが、何も重ならないようにしてください。
マイレイアウト: -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10"
android:id="@+id/ll_gridmain"
tools:context="mohits.app.picreddit.itemgrid">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:divider="@null"
android:numColumns="2"
android:background="#454545" >
</GridView>
<LinearLayout android:id="@+id/banner_view"
android:orientation="horizontal"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:visibility="gone">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_banner"
android:visibility="gone">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
My活動: -
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("xxx")
.build();
mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
mAdView.setVisibility(View.VISIBLE);
bannerView.setVisibility(View.VISIBLE);
}
});
は私が取得しています何: -
banner_view
レイアウトが常にあっても表示されます私はに設定しています。これは、広告を表示する場合にのみ表示されます。
ありがとうございます。
ああ!ありがとうございました。 – Mohit