Saeed Rehman
Saeed Rehman

Reputation: 173

My Admob Ad Covering App Content in Tab Fragment - How to Fix

I want to know how to place admob ad in bottom of screen which don't cover any part of app content as Im using RelativeLayout in xml. Please help me to fix this issue as quick as possible thanks.

activity_main.xml

`

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="?attr/colorPrimary"
        android:elevation="6dp"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:background="?attr/colorPrimaryDark"
        android:elevation="6dp"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:tabMode="scrollable"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/tab_layout"/>


    <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="ca-app-pub-0000000000000/00000000000">
</com.google.android.gms.ads.AdView>


</RelativeLayout>

`

Upvotes: 0

Views: 395

Answers (1)

Amod Gokhale
Amod Gokhale

Reputation: 2448

     <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            ads:adSize="SMART_BANNER"
            android:layout_below="@+id/tab_layout"
            ads:adUnitId="ca-app-pub-00000000000000/00000000000"/>
</RelativeLayout>

Add adView inside your relative layout and then add android:layout_below property

Upvotes: 1

Related Questions