Showing Native Ads inside WebView content in Android?
Asked Answered
S

1

21

I want to know how to show Native ad inside webview Content at random position everytime. Suppose i am loading static html page in webview. Is it possible to show native inside webview html page at random position when user reading the content of page native ads appear inside the content.

Serving answered 2/6, 2016 at 5:52 Comment(4)
Did you found a solution? I'm interested too.Blavatsky
@Vaia Not yet trying hardServing
check #16152026 and #25227198Jenaejenda
You can arrange your WebView content and your native AdView within your xml layout the way you want (top, bottom,left, above...). However, embedding your native Ads within your webview content sounds weird. I would suggest embedding your AdViews inside your webpage. Otherwise you'd need to manipulate your html-sources, which you don't want to do ;-)Doubleheader
J
1

First of all, the title of your question is really misleading, since you are really asking about dynamic positioning of a view.

Second, what you want to do is shade AF and you will probably get a lot of negative reviews and quick uninstalls. =)

That being said, the answer to your question is yes.

The easiest way to achieve this is by setting the initial Y position of the webview to 0 (at the top of the screen) and then use View#setTranslationY with a random value, which shifts the Y position. If you really want to annoy the users you can even animate it like this:

val random = Random()
val translation = random.nextInt(40)
webview.animate().translationYBy(translation.toFloat()).start()

Link to documentation of translationY

Jaquenette answered 3/10, 2019 at 14:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.