android - CropResolutionPolicy and AdMob in andEngine not working together -


i try show ads in game. here method use that:

@override public void oncreate(bundle savedinstancestate){     super.oncreate(savedinstancestate);  //public void onsetcontentview(){      //super.onsetcontentview();     setcontentview(r.layout.activity_main);      this.adview = new adview(this);     this.adview.setadsize(com.google.android.gms.ads.adsize.smart_banner);     this.adview.sety(50);      this.adview.setadunitid("here goes id");      com.google.android.gms.ads.adrequest adrequest = new com.google.android.gms.ads.adrequest.builder().addtestdevice(com.google.android.gms.ads.adrequest.device_id_emulator).build();      this.adview.loadad(adrequest);      relativelayout layout = (relativelayout)findviewbyid(r.id.relativelayout);      relativelayout.layoutparams params = new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content);        layout.addview(this.mrendersurfaceview);     layout.addview(this.adview, params);    } 

and xml layout:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id ="@+id/relativelayout" android:layout_width="match_parent" android:layout_height="match_parent"  tools:context="com.hsdev.salesrep.mainactivity" > 

without layout , ad cropresolution policy woked good. after adding layout stretched bit. when tried change ratioresolutionpolicy alligned left (in horizontal view, margin on right side, , not on both in andengine). question is: how can use layout (because want show ad, , still use resoltion policies andengine?

ok, answer simple...just need set gravity.:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id ="@+id/relativelayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" tools:context="com.hsdev.salesrep.mainactivity" > </relativelayout> 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -