android - 如何在阅读模式下使用 webView kotlin?
问题描述
我有一个应用程序,我想用阅读模式打开 URL 没有广告或读者不需要看到的东西
我该怎么做才能在 kotlin 中启用阅读模式?
解决方案
尝试使用 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");
}
}
推荐阅读
- authentication - 将验证合法性的厚客户端应用程序将自身检查回源
- c# - 在 Entity Framework Core 中播种关系数据
- angular - 无法使用 Angular 11 中的 ViewChild 访问子组件属性
- r - 旋转和聚合表格线
- python - 如何在 Chrome 中双击打开 Jupyter Notebook 作为 Windows 上的桌面应用程序
- angular - Firebase 消息服务工作人员发送通知
- c++ - 货币转换器 C++ 给出括号错误
- c++ - 将名称读入带空格的字符串c ++
- r - 执行栅格像元值 [r] 的空间预测
- node.js - 从节点脚本中提取 bash 命令建议