2

Recently i developed a Webapp in codeignitor(php). Now i am trying to convert into WebviewActivity for Android.

Activity when open in Android browser

it works fine

it works fine

but when opened in Webview activity App i get this

Half side of Website blank

Half side of Website blank Methods i tried

  • webView.setWebViewClient(new WebViewClient() )
  • webView.setWebChromeClient(new MyWebChromeClient(this))

i have been stuck on this problem from several hours. searched everywhere but did not find the right answer

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <WebView
        android:id="@+id/activity_main_webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Ahmed Mujtaba
  • 744
  • 5
  • 16

1 Answers1

0

here you go...try this

<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</android.support.constraint.ConstraintLayout>



    WebView browser = (WebView) findViewById(R.id.webview);

    browser.getSettings().setJavaScriptEnabled(true);
    browser.getSettings().setDomStorageEnabled(true);

    browser.loadUrl(url);

    browser.setWebViewClient(new WebViewClient(){

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url){
            view.loadUrl(url);
            return true;
        }
    });
Atif AbbAsi
  • 5,633
  • 7
  • 26
  • 47