Open AndroidDeveloperLB opened 1 year ago
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 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
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 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
Request recorded. Closing the issue.
@JillSong Why close? This means it's now possible?
@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.
Maybe I misunderstood. Are you ok with specifying it at request time, you just want to be able to do it through code?
@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.
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.
Currently it's available only in layout XML file...
https://developers.google.com/admob/android/native/templates