Webview? Display webpage in part of app screen
Monkey Targets Forums/Android/Webview? Display webpage in part of app screen
| ||
Hello all, I've been playing around with the "webview" object with no luck (android.webkit.WebView) - not sure if this is the right way to go about it though either. Is there a way I can display a webpage in only part of the android application screen. Basically I want to be able to use the android app that monkey generates and interact normally but also be able to display images/text from a webpage on part of that display. I know how to launch a browser activity from the app but that has two problems - one it is full screen and two it suspends the monkey activity. Any help would be appreciated, thanks, Matt |
| ||
bump.. Anyone know how to display a webview within the activity...like a smaller webview within the main game activity... The intention is to display ads through a webview which is visible within the main game activity at certain points...although there are many other uses for it too.... |
| ||
Anyone? |
| ||
Yes - it can be done... You'll need to edit your layout (main.xml) And change it to a relative layout. NOTE: My code sets it to full-screen (fill_parent). You'll need to edit the layout params. My code overlays some buttons for Next/Prev (with main.xml) and the main monkey code queries them and makes the WebView point to a different local page. The loadURL could easily be a remote server... |
| ||
Thanks MonkeyPig - that is a good start. I must admit, not being all that familiar with java I'm not entirely sure where to put the code you've shown above - in an extern? Also - is there a way to show/hide the webview at different points of the program execution. I will look up how to do a relative layout. |
| ||
Yes - you need to add the java code to some native module and access it from Monkey with Extern. There are many examples of this dotted throughout the thread. But here's a quick snipper... It's fairly easy to show/hide/position native Android UI elements. You should (if you haven't already) go read through the Android SDK documents. There's a lot of really useful stuff in there - including how to do different layouts and add many different standard UI elements to your main.xml. Querying/updating the state of these UI elements will require you to dig into java and the Android docs. I use these functions to hide the xml views. Not tested with WebView but fairly sure it inherits from the View class. [codebox] static void HideViewByID(int buttonResID) { View view = MonkeyGame.activity.findViewById( buttonResID ); view.setVisibility(View.GONE); } static void ShowViewByID(int buttonResID) { View view = MonkeyGame.activity.findViewById( buttonResID ) ; view.setVisibility(View.VISIBLE); } [codebox] |