2017-06-09 32 views
0

私は画面の下部に広告を表示しようとしています。バナー広告の上側にあるスクロールビューポートがあります。その代わりに、重複している:バナー広告付きのLinearLayoutを画面下部に配置

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <include 
      layout="@layout/toolbar_main"/> 
     <RelativeLayout 

      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|enterAlways"> 

      <ImageView 
       android:id="@+id/tabImage" 
       android:layout_width="100dp" 
       android:layout_height="150dp" 
       android:scaleType="centerCrop" 
       android:layout_centerHorizontal="true" 
       /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:text="Anime Title" 
       android:id="@+id/tabTitle" 
       android:layout_below="@id/tabImage" 
       android:layout_centerHorizontal="true" 
       android:gravity="center"/> 

     </RelativeLayout> 

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

    </android.support.design.widget.AppBarLayout> 

    <LinearLayout xmlns:ads="http://schemas.android.com/apk/res-auto" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center|bottom" 
     android:background="#000000" 
     android:orientation="vertical"> 

     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal|center" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      ads:adSize="BANNER" 
      ads:adUnitId="@string/banner"> 
     </com.google.android.gms.ads.AdView> 

    </LinearLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

</android.support.design.widget.CoordinatorLayout> 

私が間違ってやっている:

enter image description here

ので、広告がRecyclerViewとスクロールviewpagerの背後にあるが...

これはレイアウトコードです?

よろしく、

答えて

0

は、このレイアウトを試してみてください:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <include 
      layout="@layout/toolbar_main"/> 
     <RelativeLayout 

      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|enterAlways"> 

      <ImageView 
       android:id="@+id/tabImage" 
       android:layout_width="100dp" 
       android:layout_height="150dp" 
       android:scaleType="centerCrop" 
       android:layout_centerHorizontal="true" 
       /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:text="Anime Title" 
       android:id="@+id/tabTitle" 
       android:layout_below="@id/tabImage" 
       android:layout_centerHorizontal="true" 
       android:gravity="center"/> 

     </RelativeLayout> 

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

    </android.support.design.widget.AppBarLayout> 

    <LinearLayout xmlns:ads="http://schemas.android.com/apk/res-auto" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#000000" 
     android:orientation="vertical"> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal|center" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      ads:adSize="BANNER" 
      ads:adUnitId="@string/banner"> 
     </com.google.android.gms.ads.AdView> 

    </LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 
+0

私はちょうどそれを追加し、ViewPagerは、私はいくつかの変更を行っ – emboole

+0

をdissapeared。もう一度お試しください。 –

関連する問題