티스토리 뷰

Android Kotlin Admob 안드로이드 코틀린 애드몹 

이제부터 코틀린 열심히 배워볼랍니다. 

무엇보다도 광고를 넣는 방법을 알아야 돈을 벌죠. 돈을 벌어야 뭐든 하니까요. 

오늘은 안드로이드 스튜디오 코틀린을 이용하여 애드몹 광고를 넣는 방법을 터득했습니다. 

1. build.gradle(Module: app) 

implementation 'com.google.android.gms:play-services-ads:11.4.2'

 

2. 레이아웃 activity_mail.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.gms.ads.AdView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/adView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
/>

</androidx.constraintlayout.widget.ConstraintLayout>

3. 코틀린 코딩 

 

4. 애드몹 샘플 아이디는  

https://developers.google.com/admob/android/banner?hl=ko

 

배너 광고  |  Android  |  Google Developers

Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you're new to mobile advertisi

developers.google.com

 

5. 실행화면

댓글
최근에 달린 댓글
글 보관함
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Total
Today
Yesterday
    뽀로로친구에디
    최근에 올라온 글