question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] BannerAd is right aligned on some devices

See original GitHub issue

Plugin Version

0.13.0

Steps to Reproduce

I have implemented adWidget in the following format:

final Container adContainer = Container(
    color: Colors.red,
    constraints: BoxConstraints(
        minHeight: myBanner.sizes.first.height.toDouble() + 10,
    ),
    child: Column(
        children: [
            Flex(
                direction: Axis.horizontal,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                    Container(
                        color: Colors.green,
                        width: myBanner.sizes.first.width.toDouble(),
                        height: myBanner.sizes.first.height.toDouble(),
                        alignment: Alignment.center,
                        child: AdWidget(
                            ad: myBanner,
                        ),
                    )
                ],
            ),
        ],
    ),
);

Expected results:

Ad should be centered and should cover the green rectangle.

Actual results:

Ad is aligned to the right of the screen.

photo_2021-06-02 08 55 53

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
jjliu15commented, Sep 28, 2022

This appears to be happening when the size of the rendered ad does not match the AdSize that was requested.

For example, in https://github.com/googleads/googleads-mobile-flutter/issues/261#issuecomment-914229852 the size requested was fullBanner, but the image shows a 320x50 ad (most likely because 468 is too wide for the device). We make the ad container width 468, which looks nicer on iOS than Android, probably due to different default layout constraints.

I think generally we need a better way to handle the case where the returned banner ad size does not match the requested size. Maybe something similar to FluidAdWidget or with different constraints.

1reaction
timothyhoang-googlecommented, Sep 21, 2022

We’re looking into this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix All Items Right Aligned on Android
How to Fix All Items Right Aligned on Android · Now follow the way to fix – · Step-1: Tap on the Settings...
Read more >
Banner ad guidance - Google AdMob Help
The examples will help to clarify some of the most frequently used banner ad placements and whether they are aligned with our policies...
Read more >
Admob ads alignment issue in android - Stack Overflow
I have 5kV available to create a spark. Is limiting the current to 500uA as simple as putting a 10MOhm resistor in series?...
Read more >
Banner Ads | Mobile Ads SDK for Android - Google Developers
Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen...
Read more >
Android AdMob Tutorial 2022 - 02 - Display a Simple Banner Ad
In this video, we learn about how to display a simple banner from AdMob in your android application.Integrate Google Mobile Ads SDK ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found