Issue
I am loading http://www.google.com
url in the the WebView.
But, even though I am loading it from the device/simulator, the content of the webview is not getting adjusted based on the device dimensions.
If you see, Google page is not getting set properly according to the dimensions of the WebVie. But, if I open the same url in the simulator browser with same dimensions, then its loading properly with scaling etc.
How to make a webview load properly on a WebView in Android?
Here is the XML of the WebView Layout
<WebView android:id="@+id/webView1" android:layout_width="300dp" android:layout_height="300dp" android:layout_alignParentBottom="true" android:layout_below="@+id/button1" android:layout_centerHorizontal="true" />
MainActivity.java file
WebView web_view =(WebView)findViewById(R.id.webView1); web_view.getSettings().setLoadWithOverviewMode(true); web_view.getSettings().setUseWideViewPort(true); web_view.loadUrl("google.com";);
Solution
You need to change the user-agent to make it not load mobile sites.
Try this
<WebView android:id="@+id/webView1" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_alignParentBottom="true"
android:layout_below="@+id/button1" android:layout_centerHorizontal="true" />
Answered By - Daniel Lockard
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.