How to wrap a website in a phone app?

后端 未结 5 921
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 07:00

I have seen a lot of mobile phone apps that just open a web page without the controls. Just the page.

I am looking for guidance and links to start something simple like

5条回答
  •  故里飘歌
    2021-02-02 07:36

    If you would like to wrap a website in Android you may do so with this code, from Roskvist

    package com.webview;
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.Window;
    import android.webkit.WebView;
    
    public class WebViewTest extends Activity {
    
        WebView browserView;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            //Removes the title bar in the application
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.main);
    
            //Creation of the Webview found in the XML Layout file
            browserView = (WebView)findViewById(R.id.webkit);
    
            //Enable Javascripts
            browserView.getSettings().setJavaScriptEnabled(true);
    
            //Removes both vertical and horizontal scroll bars 
            browserView.setVerticalScrollBarEnabled(false);
            browserView.setHorizontalScrollBarEnabled(false);
    
            //The website which is wrapped to the webview
            browserView.loadUrl("http://dev.openlayers.org/sandbox/camptocamp
            /mobile/trunk/examples/iol-iui.html?rev=9962#_map");
    
        }
    }
    

    And here's the main.xml contents

    
    
    
    
    

    You would then have to compile and load it to your device via USB.

提交回复
热议问题