Reputation: 27
Here is my xml
<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">
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="MY - ID"
ads:adSize="BANNER"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
/>
<ListView
android:id="@+id/listView0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scrollingCache="false"
android:layout_above="@+id/adView" >
</ListView>
</RelativeLayout>
New admob advertisement does not allow
ads:loadAdOnCreate="true"
method to use.
i want to position my advertisement end of the page and center. Also, if i have not internet connections there is advertisement area but no advertisement.How can i fix this?
Upvotes: 0
Views: 575
Reputation: 7641
Use below code in xml :
<RelativeLayout
android:id="@+id/rlTop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/rlBottom"
android:layout_alignParentTop="true" >
<ListView > </ListView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center" >
<!-- place your xml ad code here -->
</RelativeLayout>
You can refer above sample xml code for placing ads at bottom.
Upvotes: 0
Reputation: 124
Try creating a different XML file for your google admob and include it in your main layout.
This way you can design your layout much more easier.
<include layout="@layout/admob"/>
By the way you can set the visibility of your layout either in your java code or xml if you want to hide it.
Upvotes: 1