I am developing android native app. I am using image and text. So, I decided to use HTML in layout. But I don't know is it possible and if possible how.
Regards
I am developing android native app. I am using image and text. So, I decided to use HTML in layout. But I don't know is it possible and if possible how.
Regards
You can render a WebView
in your layout. This WebView
can for example point to a remote or a local resource such as a HTML/JS/CSS file.
Here is how you could declare a Webview in a layout :
<WebView
android:id="@+id/mywebview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
And use/initialize it in your code :
/* Retrieve your webview and manipulate it using a reference to
the object created in your XML */
WebView webview = (WebView) this.findViewById(R.id.mywebview);
/* If you would like to use Javascript in your view */
webview.getSettings().setJavaScriptEnabled(true);
/* Load the URL to the resource you want to load in your view */
webview.loadUrl("http://hostname/...");
Firstly, create the HTML file that you want. If you want the app to be usable without an internet connection, you will need the HTML file, the images, the CSS file and any other files that are linked to the website to be on the phone with the app.
Then, use a WebView to show the HTML page that you created.
You can see information about WebViews here (from the Android documentation): http://developer.android.com/reference/android/webkit/WebView.html