googleads-mobile-android-native-templates icon indicating copy to clipboard operation
googleads-mobile-android-native-templates copied to clipboard

Request: allow to set template type during runtime

Open AndroidDeveloperLB opened this issue 11 months ago • 10 comments

Currently it's available only in layout XML file...

https://developers.google.com/admob/android/native/templates

<com.google.android.ads.nativetemplates.TemplateView...
   app:gnt_template_type="@layout/gnt_small_template_view" ... />

...

AndroidDeveloperLB avatar Jul 21 '23 08:07 AndroidDeveloperLB

Hi @AndroidDeveloperLB

Can you expand further on what you are wanting and your specific use case? Are you asking to construct the template view in code without a xml file ?

NVentimiglia avatar Jul 28 '23 00:07 NVentimiglia

@NVentimiglia Sometimes you load an ad that has media, and sometimes you don't. For example, if you fail to load an ad that has media, you might want to have a fallback to load an ad that doesn't. Once you have the ad, you will choose which template type to use here. But currently this is only possible via layout XML and not via Java/Kotlin.

AndroidDeveloperLB avatar Jul 28 '23 08:07 AndroidDeveloperLB

@AndroidDeveloperLB

Got it, you would like to define the view in pure Java / Kotlin without the XML file. I will bring this us as a needed enhancement.

NVentimiglia avatar Jul 28 '23 16:07 NVentimiglia

@NVentimiglia It's not necessary without XML, just the part of the "gnt_template_type" , to be set in Java/Kotlin. Of course, if there are more things that are only in XML, please consider having them in Java/Kotlin, as well

AndroidDeveloperLB avatar Jul 28 '23 18:07 AndroidDeveloperLB

Request recorded. Closing the issue.

JillSong avatar Nov 06 '23 15:11 JillSong

@JillSong Why close? This means it's now possible?

AndroidDeveloperLB avatar Nov 06 '23 16:11 AndroidDeveloperLB

@AndroidDeveloperLB from https://support.google.com/admob/answer/6240809, the primary image (media view asset) is guaranteed to be returned. It just may not always have video. Are you saying that if the video is not returned, you don't want to render the primary image?

The way it's defined, it's expected that you know the size of ad you want to render (that is, you know the space made available from your app) at request time.

ericleich avatar Nov 13 '23 19:11 ericleich

Maybe I misunderstood. Are you ok with specifying it at request time, you just want to be able to do it through code?

ericleich avatar Nov 13 '23 19:11 ericleich

@ericleich What video/image? Yes, the request is about the template. That we won't be forced to use as XML, and that we could use code instead, during runtime.

AndroidDeveloperLB avatar Nov 13 '23 20:11 AndroidDeveloperLB

Nevermind, My initial question didn't make sense.

Agree with the use case: "I want to create a TemplateView and add it to my view hierarchy programmatically." This would require some API to be able to pass the template type.

ericleich avatar Nov 14 '23 18:11 ericleich