I have a website built on top of PrimeFaces. My problem is that the content and the images on the WebView appear larger than on Chrome. What should I do to make rendering on WebView identical to that of Chrome?
Scaling does not seem to help because the website has a responsive design. I have also tried wrap_content
instead of fill_parent
with no success.
Update 1: The followings have no effect. I have excluded them from the code below to keep it minimal.
WebViewClient
ChromeViewClient
setLoadWithOverviewMode(true)
setUseWideViewPort(true)
Update 2:
setInitialScale()
has no effect.
MyActivity.java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.web_engine);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
if (savedInstanceState == null) {
webView.loadUrl("http://www.primefaces.org/showcase/mobile/index.xhtml");
}
}
main.xml
<RelativeLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:background="#ffffff"
a:orientation="vertical" >
<WebView a:id="@+id/web_engine"
a:layout_width="fill_parent"
a:layout_height="fill_parent"
/>
Try:
Mentioned here: http://developer.android.com/guide/webapps/migrating.html
More specifically here: http://developer.android.com/reference/android/webkit/WebSettings.LayoutAlgorithm.html#TEXT_AUTOSIZING
Full code here: