0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Kotlinで地図アプリ(ゴミ拾いアプリ)。(19日目) AdMob広告の実装

Posted at

今日やった事

・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の理解度が低い事が問題…。

その辺りの根本的な勉強をゼロからした方が良いかもです。

参考サイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?