how to add external css file on html page in Android

前端 未结 1 1898
眼角桃花
眼角桃花 2021-01-07 05:53

I am working on an application with many html pages. I have created these in the raw folder on Eclipse.

I\'m going to be making many html files and I want to have o

1条回答
  •  梦毁少年i
    2021-01-07 06:42

    you can copy html and css files in your project assets and load html file from asset to webview like below code:

        WebView wv;  
        wv = (WebView) findViewById(R.id.webView1);  
        wv.setBackgroundColor(0);
        wv.setBackgroundResource(android.R.color.black);
        wv.setWebChromeClient(new WebChromeClient());
        wv.setWebViewClient(new WebViewClient());
        wv.getSettings().setJavaScriptEnabled(true);
        wv.getSettings().setPluginsEnabled(true);
        wv.loadUrl("file:///android_asset/Index_Animation/test.html");
    

    like below screen shot:

    enter image description here

    and refer css in html file below:

    
    
    
    
      
                
    
                    

    0 讨论(0)
提交回复
热议问题