GingerGirl GingerGirl - 2 years ago 162
Android Question

How to keep responsive layout in WebView Android app?

I have created an Android app using

. This app shows the content of a website. There are many internal links and external links (with a 301 redirect). Internal links are correct, but when I tap on external links, I see a fullscreen desktop layout instead of the responsive version of the page and it looks very bad.

How do I edit the following code in order to always get the responsive layout to fit the screen?

webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(final WebView view, String url) {
// hide loading image
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
public void run() {
}, 1000);
public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage(description).setPositiveButton(getText(R.string.ok), null).setTitle("onReceivedError");;


// load url (if connection available
if (isInternetConnected(this)) {
String URL = "";
// showAlertDialog(this, "No Internet Connection",
// "You don't have internet connection.", false);
new AlertDialog.Builder(this)
.setTitle("No Internet Connection")
.setMessage("You don't have internet connection.")
.setPositiveButton("Retry", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// whatever...
finish(); //Close current activity
startActivity(getIntent()); //Restart it


Answer Source

Actually you are testing on a tablet and amazon website looks similar to desktop version from a tablet, while it becomes responsive when browsed from a phone.

Please try from a standard phone and you'll see that its mobile version of the site :)

Please let me know in case your problem isn't solved.



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download