2016-07-14 5 views
1

Я пытаюсь реализовать рекламу в нижней части экрана, кто-то сказал мне, что мне нужно изменить linearlayout на RelativeLayout, но когда я делаю это, панель инструментов как-то уменьшится, а вкладки начнутся смотреть strange.So Я думаю, что там могут быть некоторые вещи, которые мне нужно изменить или добавить к RelativeLayout, что я не знаю, вот мой LinearLayout здесьОбъявления Admob не отображаются в закладке с фрагментами Linringayout

<?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

Поскольку не существует образ того, что вы хотите, я могу только догадываться. Но это должно сработать:

<?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" 
/> 
Смежные вопросы