Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 236

franciscoWuLin
Aspiring developer
Profile
Posts: 23
Reg: Mar 15, 2013
Kaohsiung
8,680
05/01/13 11:53 PM (12 years ago)

AdMob banner only shows at the Top of screen_menubuttons.xml

I'm trying to include some ad banner in the main screen, in this case a menu button. Have tried all different locations of the Adview block inside the screen_menubuttons.xml code, but it only works when placed below the main LinearLayout. The problem is that it shows the banner in the top of the screen and I prefer it to show in the bottom. It does this in spite of having this: android:layout_alignParentBottom="true"> The message LogCat gives me when I place it just above the last </LinearLayout> is that Not enough space to show ad! Wants: <320, 50>, Has: <320, 0> Please help if you can. Tks! Francisco
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
05/02/13 03:14 AM (12 years ago)
@franciscoWuLin - android:layout_alignParentBottom="true"> will only work inside a relative layout. If you put the admob code in the linear layout you'll have to make some margin dp top/bottom adjustments. Try putting the admob code inside the existing relative layout then you can apply the alignParentBottom: <RelativeLayout android:id="@+id/containerViewHorizontal" android:background="@android:color/transparent" android:padding="0dip" android:layout_margin="0dip" android:orientation="horizontal" 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="*************" android:layout_alignParentBottom="true" ads:adSize="SMART_BANNER" ads:loadAdOnCreate="true"/> That should work, but you may still need to apply some padding or margin.
 
franciscoWuLin
Aspiring developer
Profile
Posts: 23
Reg: Mar 15, 2013
Kaohsiung
8,680
like
05/02/13 04:14 AM (12 years ago)
Hi Raveyd, I tried doing my homework before replying, but haven't been successful. A few questions I have: 1. This line xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" does it stay with the Linear layout or does it move below the Relative layout start? 2. What margins and padding should I play with, the main Linear, or the Relative, or both? Tks a bunch again for your kind help! Francisco
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
05/02/13 04:24 AM (12 years ago)
Hi Francisco, you can keep the xmlns line where it is. Try my example above first, it may be all you need to do. How have you set up the buttons in your control panel? (vertical left, grid, horizontal bottom etc). Depending on your button layout there might be some more tweaking needed yet, but try my example first and post back.
 
franciscoWuLin
Aspiring developer
Profile
Posts: 23
Reg: Mar 15, 2013
Kaohsiung
8,680
like
05/02/13 04:43 AM (12 years ago)
Unfortunately, it didn't work. It is a grid, only 4 image buttons with label text below. Button size for small devices is 170 and margin 20, corner radius 2, font size 16. <LinearLayout 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:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/verticalScrollView" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tableLayout" android:layout_width="fill_parent" android:layout_height="fill_parent"> </TableLayout> </ScrollView> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/containerViewHorizontal" android:background="@android:color/transparent" android:padding="0dip" android:layout_margin="0dip" android:orientation="horizontal" 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="*****" android:layout_alignParentBottom="true" ads:adSize="SMART_BANNER" ads:loadAdOnCreate="true"> </com.google.ads.AdView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/containerViewHorizontalBottom" android:background="@android:color/transparent" android:padding="0dip" android:layout_margin="0dip" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/horizontalScrollView" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/containerHorizontalButtons" android:background="@android:color/transparent" android:padding="0dip" android:layout_margin="0dip" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> </LinearLayout> </HorizontalScrollView> </LinearLayout> </RelativeLayout> </LinearLayout> Hope you can help, otherwise, I think I'm finding the top placement only on this screen acceptable (in exchange of sanity). Cheers, Francisco
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
05/02/13 07:08 AM (12 years ago)
The joys of Android.. If you're not insane now you will be soon! Ok, I set up your button configuration and ads show up at the bottom of the screen on a large device - htc one x, but not on a small one - htc wildfire. So it's margins or padding... somewhere... I think use the top placement for now. I'm going to have a play with it, I'll post if I get anywhere.
 
franciscoWuLin
Aspiring developer
Profile
Posts: 23
Reg: Mar 15, 2013
Kaohsiung
8,680
like
05/02/13 07:47 AM (12 years ago)
Good grief, don't blame it on me if you fall ill. (but thanks for the progress). Actually, after I received your help yesterday for the background audio and saw you declare yourself to be an "Aspiring developer", I went into my profile to see if there was anything more appropriate to my level... like mad, but optimistic. cheers! Francisco
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
05/02/13 07:54 AM (12 years ago)
lol! They don't have my level either - "Copy/paste and see what happens Veteran"!
 
franciscoWuLin
Aspiring developer
Profile
Posts: 23
Reg: Mar 15, 2013
Kaohsiung
8,680
like
05/02/13 09:25 AM (12 years ago)
It takes a beagle-ninja at least to get to THAT, which to copy/paste. kudos!
 

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.