The MainActivity is extending UnityPlayerActivity.
We are using the following code snippet to place banner ads on android.
FrameLayout layout1 = new FrameLayout(this);
BurstlyAnimatedBanner levelUpBanner = new BurstlyAnimatedBanner( this, layout1, new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT), "0455184989016204562", "Level_Up_Screen", 30, false);
LayoutParams lp1 = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
addContentView(layout1,lp1);
Doing this is showing the ads at the top-left corner of the screen. I need the ads at the top-center of the screen. I tried using layout1.setForegroundGravity(Gravity.CENTER); but that did not help. How can I achieve what I need? Also, I need to do this programatically and cannot use and xml.
I'm the developer of the Burstly Unity plugin at github.com/Burstly/BurstlyUnityPlugin.
You can center the banner ad by adding it to a RelativeLayout instead of a FrameLayout as we do in the plugin:
With this, you can then position the banner at will. If you wish to position it at the top center, then you'd want to change
lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT)
tolp.addRule(RelativeLayout.CENTER_HORIZONTAL)
.