xcode - google play services ad is displaying in corner in android -
i have developed game in xcode using cocos2d-x & converted android.then added google play services ad, displaying in leftsidecorner. want display in middle. please me find solution.
private point getdisplaysize(display d) { if (build.version.sdk_int >= build.version_codes.honeycomb) { return getdisplaysizege11(d); } return getdisplaysizelt11(d); } @targetapi(build.version_codes.honeycomb_mr2) private point getdisplaysizege11(display d) { point p = new point(0, 1); d.getsize(p); return p; } private point getdisplaysizelt11(display d) { try { method getwidth = display.class.getmethod("getwidth", new class[] {}); method getheight = display.class.getmethod("getheight", new class[] {}); return new point(((integer) getwidth.invoke(d,(object[]) null)).intvalue(), ((integer) getheight.invoke(d, (object[]) null)).intvalue()); } catch (nosuchmethodexception e2) // none of these exceptions should ever occur. { return new point(-1, -1); } catch (illegalargumentexception e2) { return new point(-2, -2); } catch (illegalaccessexception e2) { return new point(-3, -3); } catch (invocationtargetexception e2) { return new point(-4, -4); } } @override protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on); int width = getdisplaysize(getwindowmanager().getdefaultdisplay()).y; framelayout.layoutparams adparams = new framelayout.layoutparams( layoutparams.wrap_content, layoutparams.wrap_content); adparams.gravity = gravity.bottom; adview = new adview(this); adview.setadsize(adsize.banner); adview.setadunitid(ad_unit_id); adrequest adrequest = new adrequest.builder() .addtestdevice(adrequest.device_id_emulator) .addtestdevice("hash_device_id") .build(); adview.loadad(adrequest); adview.setbackgroundcolor(color.black); adview.setbackgroundcolor(0); addcontentview(adview,adparams); _appactiviy = this; }
in above code make following changes.
find below code
adparams.gravity = gravity.bottom;
change follows
adparams.gravity = gravity.center_horizontal | gravity.bottom;
then add display in middle of application bottom.
Comments
Post a Comment