How to embed html 5 into Android mobile app

Reported answer
How to embed html 5 into Android mobile app
Ask online customer service
Scan the code to ask online customer service
  • Number of answers

    six

  • Number of browses

    7,657

6 answers Default sorting
  • Default sorting
  • Sort by time

Adopted
The WebView component can be used by embedding HTML5 into the Android mobile app. First, import WebView related libraries and jar files into the Android project. Then, add a WebView element in the XML layout file, get the element in the code, and set its attributes. Next, assign the HTML code to the htmlText attribute of WebView.
Before actual operation, you need to determine whether the current APP supports the WebView function. If supported, the following code examples can be used:
```
//Get WebView Object
WebView webview = (WebView) findViewById(R.id.webview);
//Set web page style
webview.getSettings().setJavaScriptEnabled(true); // Enable JavaScript
webview.getSettings().setAllowJavaScriptInWebApps(true); // Enable Allow JavaScript Code Execution in Web Pages
webview.getSettings().setAllowFileAccess(true); // Enable Allow Reading Local Files
//Embed HTML5 code into WebView
String html="Test Hello, World!";
webview.loadDataWithBaseURL(null, html, "text/html", null);
```
The above code loads a simple HTML page in WebView and outputs a piece of text in it. When running the APP, users can see the text "Hello, World!".
Note that you may encounter cross domain problems when using WebView. When the domain name of the web page is different from that of the APP, cross domain problems will occur. This problem can be solved by adding cross domain allowed attributes in the WebView settings.
In addition, if you need to execute JavaScript code in WebView, you need to first obtain the inputText property of WebView and assign it to a string variable. Then you can use this variable to perform some operations.
To sum up, it is very simple to embed HTML5 into WebView in Android development. Just judge whether the current APP supports the WebView function, and then set the relevant properties. I wish all developers can successfully embed HTML5 into their own APP.
cancel comment
Directly build a browser kernel in android, but you need to deploy HTML5 files to a server
cancel comment
Use wow.js, which is a plug-in, to add scrolling effect animation to the page. If you write, you can listen to the mouse scrolling event, and use the ANIMATE of JQUERY to write it. It is very simple,
cancel comment
Packaged into Android with phonegap
Or you can use a webview to load the html interface
cancel comment
Method of embedding HTML5 into APP:
1. The android webview control loads html5;
2. That is, webview supports html5 based on the webkit kernel;
3. Do custom screen adaptation debugging and testing!
cancel comment
ZOL Q&A > Smoke lampblack machine > Other classifications > How to embed html 5 into Android mobile app

Related products

  •  Jinzheng ML5

    Jinzheng ML5

    Reference price: ¥ 4998 Score:-

    Hot ranking list: not listed

  • Jingdong Search

Ranking of popular range hoods

See more rankings>

report

Thank you for contributing to the harmony of the community. Please select the type of report

Reported successfully

It will be handled after verification
Thank you for your contribution to community harmony

Scan the code to participate in the trial of new products at 0 yuan
You can get the sheets and grand gifts on the top floor

 Scan and pay attention to us
Tips

Are you sure you want to cancel this registration and exit this activity?