Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Webview - XML?

Tags:

android

Is there a way to define a webview in the layout xml rather than in the code.

And if so how? Or is it recommended that it's coded in to an activity?

like image 889
panthro Avatar asked Aug 02 '12 14:08

panthro


People also ask

Is Android WebView deprecated?

This interface was deprecated in API level 12. This interface is now obsolete.

How does WebView work in Android?

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.


1 Answers

Yes as above use the WebView tag:

<WebView android:id="@+id/webview"
android:layout_width="fill_parent" android:layout_height="50dip"/>

A sample application can be found here: http://www.androiddom.com/2011/04/creating-android-calculator-tutorial.html

The author creates a calculator that uses the WebView which is specified in the main.xml layout.

like image 131
Lucian Avatar answered Oct 16 '22 21:10

Lucian