2016-07-14 6 views
1

내 화면 하단에 광고를 구현하려고하는데 누군가가 선형 레이아웃을 RelativeLayout으로 변경해야한다고 말했지만 툴바가 작아지고 탭이 시작됩니다. 이 아니기 때문에 내가 변경하거나 내가 여기 모르는 RelativeLayout의에 추가해야 할 몇 가지가있을 수 있습니다 생각 strange.So을 보는 것은 아래로 여기Admob 광고가 단락으로 탭으로 표시되지 않음

<?xml version="1.0" encoding="utf-8"?> 
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    xmlns:tools="http://schemas.android.com/tools" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
 

 
    android:orientation="vertical" 
 
    tools:context="com.example.Jus.Forever.MainActivity"> 
 

 
    <android.support.v7.widget.Toolbar 
 
     android:id="@+id/toolbar" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="?attr/actionBarSize" 
 
     android:background="?attr/colorPrimary"/> 
 

 
    <android.support.design.widget.TabLayout 
 
     android:id="@+id/tabs" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="wrap_content" 
 
     app:tabGravity="fill" 
 
     app:tabMode="fixed" 
 
     android:background="@color/colorPrimary"/> 
 

 
    <android.support.v4.view.ViewPager 
 
     android:id="@+id/viewPager" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent"/> 
 

 
    <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="@string/banner_footer"> 
 
    </com.google.android.gms.ads.AdView> 
 

 
</LinearLayout>

답변

0

내있는 LinearLayout입니다 네가 원하는 이미지를 나는 단지 추측 할 수있다. 하지만이 작업을해야합니다 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    tools:context="com.example.Jus.Forever.MainActivity"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary"/> 

    <android.support.design.widget.TabLayout 
     android:layout_below="@id/toolbar" 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabGravity="fill" 
     app:tabMode="fixed" 
     android:background="@color/colorPrimary"/> 

    <android.support.v4.view.ViewPager 
     android:layout_below="@id/tabs" 
     android:id="@+id/viewPager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <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="12345"> 
    </com.google.android.gms.ads.AdView> 

</RelativeLayout> 
+0

예이 마지막 요소는 다른 모든 이상 그릴 것 RelativeLayout의로 문제를 해결해야한다. 그리고 layout_below가 위치 지정을 수정합니다. –

0

전체 화면을 소비하도록 ViewPager에 지시했습니다.

변경이로 :

<android.support.v4.view.ViewPager 
     android:id="@+id/viewPager" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
/> 
관련 문제