marcojak / MTAdmob

Admob plugin for Xamarin Android and iOS
https://www.xamarinexpert.it/admob-made-easy/
160 stars 26 forks source link

Banner does not update width when changing orientation #76

Closed Junior-OliveiraDeveloper closed 3 years ago

Junior-OliveiraDeveloper commented 3 years ago

The banner width does not change when rotating the device Steps to reproduce the behavior: Screenshots added I'm not sure I'm missing somethin WhatsApp Image 2021-10-08 at 17 58 58 WhatsApp Image 2021-10-08 at 17 59 22 g.

marcojak commented 3 years ago

Have you tried to reload the banner when the orientation is changed?

Junior-OliveiraDeveloper commented 3 years ago

I didn't try, I'll do it today and come back here. Thank's for your time.

Junior-OliveiraDeveloper commented 3 years ago

Hi!

This way it worked. I don't know if it's the best option. stkAds is a stackLayout

    protected override void OnSizeAllocated(double width, double height)
    {
        base.OnSizeAllocated(width, height);

        if(_width != width)
        {
            _width = width;
            var ads = new MTAdView();
            if (Device.Idiom == TargetIdiom.Phone) ads.HeightRequest = 50;
            else if (Device.Idiom == TargetIdiom.Tablet) ads.HeightRequest = 90;
            stkAds.Children.Clear();
            stkAds.Children.Add(ads);
        }
    }