Skip to content

Customize the color of the white border arround NativeAds #842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
svprdga opened this issue May 12, 2023 · 9 comments
Closed

Customize the color of the white border arround NativeAds #842

svprdga opened this issue May 12, 2023 · 9 comments
Labels
e2-days Effort: < 5 days native ad Issues related to Native Ad p2-medium platform-android Android applications specifically proposal Proposal for a change

Comments

@svprdga
Copy link

svprdga commented May 12, 2023

Use case

The new NativeAd can now be customized with colors from Dart code. However there is a padding space between the ad components and the gray outer boundary which is always white. Right now, even if the app is in Dark mode, that space is white. It would be nice if that white space could be customized, so that it could be put in a Dark tone.

Proposal

Add a paddingColor or similar property in NativeTemplateStyle in order to be able to set the color of that space which right now is always white.

@huycozy huycozy added the in triage Issue currently being evaluated label May 12, 2023
@huycozy
Copy link
Collaborator

huycozy commented May 12, 2023

Hi @svprdga
Can you please provide a minimal sample code along with a screenshot of the issue? Thank you!

@huycozy huycozy added the feedback required Further information is requested label May 12, 2023
@NaMeTaKeN33
Copy link

NaMeTaKeN33 commented May 12, 2023

I'm not OP, but was browsing I'm in the process of implementing and was looking around and saw the open post that I also ran into. This is 100% the code from the implementation guide here: https://developers.google.com/admob/flutter/native/templates

The below images are what I assume OP is talking about. Left is Android, right is iOS. Note that this only occurs on Android.

Just as an addition: On Android, setting the background colors of the Ad to transparent also sets it to whatever that border color is so it seems that whatever container the ad details are in/over has a padding and a bg color. Also the constrained box templates in the code linked above does not auto-expand the height based on if there is a video or not in the small template.

Screenshot 2023-05-12 at 10 24 24 AM

EDIT After playing around a bit more and altering the button colors, it appears to be an issue with android padding in general. Android left - iOS right

Screenshot 2023-05-12 at 1 35 36 PM

@NaMeTaKeN33
Copy link

NaMeTaKeN33 commented May 19, 2023

Just as a temporary fix: You can change the following lines in "gnt_small_template_view.xml"

Line 16: Find
android:background="@drawable/gnt_outline_shape"

Replace With
android:background="@android:color/transparent"

Not sure if it's a proper fix, but it works for now:

Screenshot 2023-05-18 at 7 34 15 PM

@huycozy
Copy link
Collaborator

huycozy commented May 26, 2023

Thank @NaMeTaKeN33 for providing more information. I also can see the issue as you described.

To reproduce the issue, enable dark theme (ThemeData.dark()) for the plugin example at:

@huycozy huycozy added p2-medium e2-days Effort: < 5 days platform-android Android applications specifically native ad Issues related to Native Ad proposal Proposal for a change and removed feedback required Further information is requested in triage Issue currently being evaluated labels May 26, 2023
@huycozy
Copy link
Collaborator

huycozy commented Jul 21, 2023

We’re closing this issue due to inactivity. If you’re still impacted, please create a new issue via the Developer Forum.

@huycozy huycozy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
@NaMeTaKeN33
Copy link

Lmao why was this closed due to inactivity? It's still an issue considering that there hasn't been a version bump and was on development sides plate.

@ravitaak
Copy link

ravitaak commented Sep 7, 2023

image
~AppData\Local\Pub\Cache\hosted\pub.dev\google_mobile_ads-3.0.0\android\src\main\res\drawable\gnt_outline_shape.xml

@svprdga @NaMeTaKeN33 @huycozy
I have changed this file and color and border set as transparent. Can you tell me I can do it? will it effect my ads?

NOTE: after changing it I can change background color in flutter by adding Container or else.

@alphonse-va
Copy link

alphonse-va commented Oct 5, 2023

If you need a less quick and dirty fix that work with your CI environnement

Replace

google_mobile_ads: ^3.0.0

By this forked repo repo

google_mobile_ads: # ^3.0.0
    git:
      url: https://github.com/alphonse-va/googleads-mobile-flutter.git
      path: packages/google_mobile_ads
      ref: 321c0a8e9bf6594c5d6d24e0aa1baf44208d2361

@ajith-ab
Copy link

ajith-ab commented Oct 6, 2024

For IOS Comment following line

ios/Classes/NativeTemplates/GoogleAdsMobileIosNativeTemplates/GADTTemplateView.m inside the package file

This helps me change the border and color.

- (void)applyStyles {
  // self.layer.borderColor =
  //     [GADTTemplateView colorFromHexString:@"E0E0E0"].CGColor;
  // self.layer.borderWidth = 1.0f;
  [self.mediaView sizeToFit];
  if ([self styleForKey:GADTNativeTemplateStyleKeyCornerRadius]) {
    float roundedCornerRadius =
        ((NSNumber *)[self styleForKey:GADTNativeTemplateStyleKeyCornerRadius])
            .floatValue;

    // Rounded corners
    self.iconView.layer.cornerRadius = roundedCornerRadius;
    self.iconView.clipsToBounds = YES;
    ((UIButton *)self.callToActionView).layer.cornerRadius =
        roundedCornerRadius;
    ((UIButton *)self.callToActionView).clipsToBounds = YES;
  }
...

}

happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2-days Effort: < 5 days native ad Issues related to Native Ad p2-medium platform-android Android applications specifically proposal Proposal for a change
Projects
None yet
Development

No branches or pull requests

6 participants