1

나는 ViewPager와 안드로이드 응용 프로그램은 다음과 같이 구현 :AdView가와 ViewPager

http://www.youtube.com/watch?v=C6_1KznO95A

나는 ViewPager 아래로 AdView를 구현하는 방법을 모르겠어요. ViewPager 아래에 AdView를 프로그래밍 방식 및 xml로 삽입하려고했습니다. 오류는 없지만 광고가 게재되지 않습니다.

내 XML :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<android.support.v4.view.ViewPager 
android:id="@+id/pager" 
android:layout_width="match_parent" 
android:layout_alignParentBottom="top" 
android:layout_height="0dp" 
android:layout_weight="1"/> 

<com.google.ads.AdView 
android:id="@+id/ad" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_alignParentLeft="true" 
android:layout_alignParentRight="true" 
android:layout_alignParentBottom="true" 
android:layout_below="@+id/pager" 
ads:adSize="BANNER" 
ads:adUnitId="@string/admob_publisher_id" 
ads:loadAdOnCreate="true" > 
</com.google.ads.AdView> 
</RelativeLayout> 
+0

@GavriloPrincip 같은 질문을 다시 게시하지 마십시오. 다른 사람이 응답 할 확률은 증가시키지 않지만 더 높은 평가 팀에서 경고를받을 확률이 높아집니다. 게다가, 그것은 질문 목록을 오염시키고 다른 사람들에게는 좋지 않습니다. 고맙습니다! – davidcesarino

답변

1

첫째, RelativeLayout에 대한 android:layout_weight이 없습니다.

둘째, RelativeLayout에 대해서는 android:orientation이 없습니다.

RelativeLayout이 아닌 LinearLayout을 사용하고 싶습니다. 그렇게한다면 의 세 가지 android:layout_alignParent* 속성을 android:layout_below과 같이 RelativeLayout이 아니라 LinearLayout과 같이 제거하십시오.

AdViewandroid:layout_height="wrap_content"과 작동한다고 가정하면 결과가 작동합니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

    <android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"/> 

    <com.google.ads.AdView 
    android:id="@+id/ad" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="@string/admob_publisher_id" 
    ads:loadAdOnCreate="true" > 
    </com.google.ads.AdView> 
</LinearLayout>