Reputation: 7937
I have a game activity which is based on a LinearLayout defined in XML (but if it makes the answer easier I can easily make this a FrameLayout).
Now I wish to have an interstitial advert which will reside in a WebView. I wish to load up the url in the background while the game is playing and then, at a time of my choosing, splat the WebView over the top of my game's layout.
I have seen similar issues discussed on SO, but despite reading them, I can't seem to get this to work.
The essential code I'd like to see is simply "put this full screen webview over the top of my existing views at runtime".
Upvotes: 0
Views: 388
Reputation: 46856
LinearLayout doesn't allow items to stack on top of each other AFAIK
I think you'll have to either use a dialog, or switch to a different type of parent layout. RelativeLayout is what I would probably recommend but others would probably work too.
If you go with RelativeLayout you can do something like this:
WebView wv = new WebView(this);
//load up your url and whatever else you need to do with the WebView
RelativeLayout mainLyt = (RelativeLayout)findViewById(R.id.yourMainLayoutId);
mainLyt.addView(wv);
Upvotes: 1