今日やった事
・AdMob広告の実装
build.gradle
dependencies {
implementation 'com.google.android.gms:play-services-ads:15.0.1'
AndroidManifest.xml
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
...
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
activity_maps.xml
xmlns:ads="http://schemas.android.com/apk/res-auto"
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
MapsActivity.kt
// 広告
val adView = AdView(this)
adView.adSize = AdSize.BANNER
adView.adUnitId = "ca-app-pub-3940256099942544/6300978111"
成功するも上手くいかず
広告表示自体は出来たものの、GoogleMapを表示しているfragment layoutの上に表示させる事が出来ず、挫折。
地図のサイズを縮めて、下にスペースを作り、表示させることは可能だと思います。
レイアウトの理解が乏しい
LinearLayoutなどの基本layoutでの配置は自由に出来るものの、fragmentや、DrawerLayout、ConstraintLayoutの理解度が低い事が問題…。
その辺りの根本的な勉強をゼロからした方が良いかもです。
参考サイト