Android Admob Ad Not Shown In Activity With Fragment. Why?
I have an activity as follows. I launch it inside another activity using setContentView(R.layout.below); However, below.xmlcontains a pager (which is a fragment and has its own te
Solution 1:
try removing the padding of RelativeLayout, also happens to my app, but got it working after removing the padding
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="5dp" <--- REMOVE
android:paddingRight="5dp" > <--- REMOVE
if you must use a padding, add it on parent layout of the adview, so it will be on LinearLayout
Solution 2:
Give some heights to ad view it's height depends on device screen size it can be 50dp,120dp
use this if nothing happens then please put different size and try one more time
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutandroid:id="@+id/home_layout"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:layout_above="@+id/footerLayout"><android.support.v4.view.ViewPagerandroid:id="@+id/pager"android:layout_width="fill_parent"android:layout_height="wrap_content" ></android.support.v4.view.ViewPager></LinearLayout><LinearLayoutandroid:id="@+id/footerLayout"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_centerHorizontal="true"android:layout_alignParentBottom="true"
><com.google.android.gms.ads.AdViewandroid:id="@+id/adView2"android:layout_width="match_parent"android:layout_height="80dp"android:layout_marginBottom="0dp"ads:adSize="SMART_BANNER"ads:adUnitId="@string/banner_ad_unit_id" ></com.google.android.gms.ads.AdView></LinearLayout>
Post a Comment for "Android Admob Ad Not Shown In Activity With Fragment. Why?"