Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing Native Ads inside WebView content in Android?

Tags:

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.

like image 635
Jagjit Singh Avatar asked Jun 02 '16 05:06

Jagjit Singh


People also ask

How do I show native ads?

Load an Ad. Native ads are loaded via the AdLoader class, which has its own Builder class to customize it during creation. By adding listeners to the AdLoader while building it, an app specifies which types of native ads it is ready to receive. The AdLoader then requests just those types.

What is native ads app?

Native ads match both the form and function of the user experience in which they're placed. They also match the visual design of the app they live within. These ads augment the user experience by providing value through relevant content that flows within the context of surrounding app content.


1 Answers

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

like image 105
Qw4z1 Avatar answered Oct 04 '22 22:10

Qw4z1