首页 > 解决方案 > 如何在阅读模式下使用 webView kotlin?

问题描述

我有一个应用程序,我想用阅读模式打开 URL 没有广告或读者不需要看到的东西

我该怎么做才能在 kotlin 中启用阅读模式?

标签: androidkotlinwebview

解决方案


尝试使用 WebView,在 .xml 文件中添加以下代码:

          <?xml version="1.0" encoding="utf-8"?>
           <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

和内部活动(或片段)

 import android.os.Bundle;
 import android.webkit.WebView;

 public class WebViewActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://www.google.com");
    }
 }



推荐阅读