Centering MoPub Banner Ads on Phones


#1

Hi does anyone know the best way to ensure MoPub Android banner ads are centered on newer phones such as the Pixel ?

The IOS ones work with some recentering code from the MoPub SDK docs but the Android docs have no such help.

Do I need to do some LayoutParams stuff when the Ad loads ?

Any help much appreciated !


#2

Our Android sample app already centers the banner ad horizontally. You can follow the example there and modify as needed (e.g. adding vertical centering). You can do that in the XML or in the Java code of the app. AFAIK the phones that the banners are displayed on shouldn’t affect their position/layout.

You can grab the sample app here and find it on Github here.

If you’re still having issues, please reach out to support@mopub.com