Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 93

fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
12/31/12 07:45 PM (13 years ago)

Admob and Menu with Image plugin Android

I love this plugin and was wondering if there is any way to code this screen so that the ads do not go on top of the image at top? I know this has to do with something about linear and relative layout which i don't quite understand. Any insight would be greatly appreciated. Thanks and Happy New Year :)
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
01/01/13 01:27 AM (13 years ago)
I had set up admob ads for someone from this forum few days ago. I dont remember his profile name but his name is Jordan. I think it might help you as well. Try copy pasting the following code in the screen_wb_menuimage.xml layout file. Tell me if this is what you were wanting to have. <?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/containerView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="0dip" android:background="@android:color/transparent" android:padding="0dip" > <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/headerImageView" android:layout_width="fill_parent" android:layout_height="150dip" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:scaleType="center" > </ImageView> <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/listView" ads:adSize="SMART_BANNER" ads:adUnitId="a14e2335c8b3dfc" ads:loadAdOnCreate="true" > </com.google.ads.AdView> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/headerImageView" android:layout_weight="1" android:background="@android:color/transparent" android:cacheColorHint="#000000" android:choiceMode="singleChoice" android:scrollbars="none" > </ListView> </RelativeLayout>
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
01/01/13 05:16 AM (13 years ago)
Hi @Sandeep - Happy new year! How do you like the SMART_BANNER? Good innit?
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
01/01/13 05:18 AM (13 years ago)
A very happy new year to you as well. The smart banner works like wonder. It fills up all the blank space and just ads some nice background padding to cover up it perfectly.
 
fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
like
01/01/13 10:20 AM (13 years ago)
Im Jordan lol. The code didnt work. It kept saying the ad would not show error. It only worked if there was space but that meant I could only have 2 or 3 items on the menu.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
01/01/13 02:06 PM (13 years ago)
Do you use a tabbed menu @fusionmtx? It's super easy to put the code in tabs and have a banner at the bottom of every tab screen (apparently the bottom is the best place to put a banner in an app).
 
fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
like
01/01/13 02:22 PM (13 years ago)
I have the ads in the tab layout at the bottom and the custom url screen. But I have alot of the Menu with image screens.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
01/01/13 03:21 PM (13 years ago)
Ah, I see. Try this: <?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/containerView" android:background="@android:color/transparent" android:padding="0dip" android:layout_margin="0dip" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adUnitId="xxxxxxxxxxxxx" ads:adSize="SMART_BANNER" android:layout_alignParentTop="true" ads:loadAdOnCreate="true"/> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/headerImageView" android:layout_width="fill_parent" android:layout_height="150dip" android:scaleType="center" android:layout_centerHorizontal="true" android:layout_below="@+id/adView"> </ImageView> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listView" android:background="@android:color/transparent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:cacheColorHint="#000000" android:choiceMode="singleChoice" android:layout_weight="1" android:scrollbars="none" android:layout_below="@+id/headerImageView"> </ListView> </RelativeLayout>
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.