android - NativeExpressAdView XML attribute adSize was missing -
i trying use nativeexpressadview instead of ad shows
required xml attribute 'adsize' missing
in black background, red-bordered box. adding adunit , adsize adview programmatically this
<com.google.android.gms.ads.nativeexpressadview android:id="@+id/nativeadview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"/>
java code:
nativead = (nativeexpressadview) itemview.findviewbyid(r.id.nativeadview); int widthindp = context.getresources().getconfiguration().screenwidthdp; widthindp -= context.getresources().getdimension(r.dimen.activity_horizontal_margin); nativead.setadunitid(context.getstring(r.string.dummy_ad_unit_id)); nativead.setadsize(new adsize(widthindp, 100)); nativead.loadad(adrequest);
and adrequest declared follows:
adrequest = new adrequest.builder() .addtestdevice(adrequest.device_id_emulator) .addtestdevice("dd8112531d2b704f33c3b0314744e92b") .addtestdevice("62f4961171df9f253bc3639f7b9a686b") .build();
i followed tutorial explained in official docs of firebase admob. why cannot show ads in nativeexpressadview while setting ad size dynamically?
it has been solved when added nativeexpressadview programmatically , removed xml follows.
nativead = new nativeexpressadview(this); int widthindp = context.getresources().getconfiguration().screenwidthdp; widthindp -= context.getresources().getdimension(r.dimen.activity_horizontal_margin); nativead.setadsize(new adsize(widthindp, 250)); nativead.setadunitid("myadunitid"); // create ad request. adrequest.builder adrequestbuilder = new adrequest.builder(); // optionally populate ad request builder. adrequestbuilder.addtestdevice(adrequest.device_id_emulator); // add nativeexpressadview view hierarchy. layout.addview(nativead); // start loading ad. nativead.loadad(adrequestbuilder.build());
Comments
Post a Comment