2016-07-14 11 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" 
/> 
関連する問題