How to implement CSS file in Android App

Here is the simplest way to implement your CSS file in android application.

WebViews in your native Android app, to display HTML which is packaged with the app, then you can use CSS like in any HTML site.

WebVie webView=(WebView) findViewById(R.id.webViewDetials);
//webView.setBackgroundColor(0x00000000);
webView.getSettings().setJavaScriptEnabled(true);

StringBuilder sb = new StringBuilder();
sb.append("<HTML><HEAD><LINK href=\"http://google.com/css/attribute.css\" type=\"text/css\" rel=\"stylesheet\"/></HEAD><body>");
sb.append(attributes.toString());
sb.append("</body></HTML>");
webView.loadDataWithBaseURL(null, sb.toString(), "text/html", "utf-8", null);

Happy Coding!!!

No comments:

Post a Comment

Circle

Most recent Elastic Search tutorials for beginner, intermediate and advance level developer, Yubraj Pokharel, in CodingWorkspace