Create Admob Ad

I am trying to customize my own ads from Admob programmatically, but there is almost no documentation on this from the official guide available here . I think I'm close to a solution, but I don’t see how to set its size.

The documentation says:

Publishers can also use the FULL_WIDTH constant when creating AdSize programmatically for NativeExpressAdView.

The problem is that this FULL_WIDTH block FULL_WIDTH not an AdSize module, like the others available, it just returns an integer.

Here is what I got now:

 mAdmobNativeExpressAdview = new NativeExpressAdView(this); mAdmobNativeExpressAdview.setAdUnitId(getString(R.string.mediation_native_id)); mAdmobNativeExpressAdview.setAdSize(AdSize.FULL_WIDTH); 

But the last line cannot be implemented, as setAdSize expects an AdSize object.

Is there any other way to set this attribute?

+7
android admob native-ads
source share
1 answer

Look at the sample found in the documentation.

mNativeExpressAdView.setAdSize(new AdSize(400, 100));

Where

AdSize constructor declared as

AdSize (int width, int height)

Create a new AdSize.

In your code:

mAdmobNativeExpressAdview.setAdSize(new AdSize(AdSize.FULL_WIDTH, 20));

For example, it sets the size of the advertisement for full width with a height of 20 dp.

Adjust according to your location.

+14
source share

All Articles