我正在尝试创建一个 webview activity 但整个网站都没有加载

I am Trying to create a webview activity but the whole website is not loaded

最近我在 codeignitor(php) 中开发了一个 Webapp。现在我正在尝试将 WebviewActivity 转换为 Android。

Activity 在 Android 浏览器中打开时

效果很好

但是在 Webview activity 应用程序中打开时我得到了这个

网站半边空白

我试过的方法

几个小时以来,我一直被这个问题困扰。到处搜索但没有找到正确答案

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>

给你...试试这个

<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;
        }
    });