question

Xavier Guzman avatar image
Xavier Guzman asked

Ads not being placed on bottom left corner of my game

Hello, I am just getting started with adding ads to my android game. I basically have a FrameLayout as my contentView inside my Activity. Inside the framelayout I have my game view, which is filling the screen. I am trying to add ads at the bottom left corner of the game, I have tried with both, RelativeLayout and FrameLayout, and nothing seems to work, ads will only stay at the bottom middle of the screen. Here's how I am trying to make them go to the bottom left corner (on my app's onCreate): FrameLayout layout = new FrameLayout(this); layout.add(gameView); adView = new AdLayout(this, AdSize.SIZE_300x50); // Add the Amazon AdView view LayoutParams adParams = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT); adView.setLayoutParams(adParams); layout.addView(adView); Is there anything I am missing? Greatly appreciate any help in advance
mobile ads
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Amelia@Amazon avatar image
Amelia@Amazon answered
Hello Xavier Guzman, To add ads at the bottom left corner of the game, change the following code from LayoutParams adParams = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT); to, float scale = this.getApplicationContext().getResources().getDisplayMetrics().density; LayoutParams adParams = new FrameLayout.LayoutParams((int) (300 * scale), (int) (50 * scale), Gravity.BOTTOM | Gravity.LEFT); If you have any other app specific questions, please reach out to us via our Contact Us form ( https://developer.amazon.com/help/contactus.html ). This will allow us to validate your identity and discuss app specific information in a context that will not expose your personal and proprietary information.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.