settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
参考代码如下:
mPreAgentWeb = AgentWeb.with(this)
.setAgentWebParent(mBinding.fl, new ConstraintLayout.LayoutParams(-1, -1))
.useDefaultIndicator()
.setWebViewClient(mWebViewClient)
.setAgentWebWebSettings(new AbsAgentWebSettings() {
@Override
protected void bindAgentWebSupport(AgentWeb agentWeb) {
@Override
public IAgentWebSettings toSetting(WebView webView) {
super.toSetting(webView);
getWebSettings().setTextZoom(250);
getWebSettings().setUseWideViewPort(true);
getWebSettings().setLoadWithOverviewMode(true);
return this;
.createAgentWeb();
思路参考自:
用WebView查看html页面四周有留白,怎么让他充满屏幕
AgentWeb的Wiki
调整前,调整后主要是//设置加载进来的页面自适应手机屏幕settings.setUseWideViewPort(true);settings.setLoadWithOverviewMode(true);参考代码如下:mPreAgentWeb = AgentWeb.with(this) .setAgentWebParent(mBinding.fl, new ConstraintLayout.LayoutParams(-1, -1)) .
操作:代码注释写的很详细,很容易就明白,对vue3不熟悉的小伙伴更加友好,将源码下载后拷贝进项目中,然后就可以直接将自己的大屏展示内容嵌套进去。相当于对整个可视区域进行了缩放操作,很方便快捷易懂。
自适应一直就是都是前端开发的大难题,特别是现在越来越多的项目喜欢大屏展示,今天公司给我的项目便是一个可视化大屏的项目,而且宽高只告诉了大概是4000*2000,然后使用的Vue3进行开发,网上找了一下几乎都是Vue2的解决过程,这方面Vue3的解决方法还是很少,所以小小的记录一下。
PS:对于使用transform实现可视化大屏自适应方案,需要注意在缩放过程中内容区域的图片像素是否达标,否则会出现图片缩放后模糊的情况。
AgentWeb介绍
AgentWeb是一个基于的Android WebView,极度容易使用以及功能强大的库,提供了Android WebView一系列的问题解决方案,并且轻量和极度灵活,体验请下载的 ,或者您也可以到Google Play里面下载 ,详细使用请参照上面的Sample。
Gradle
implementation 'com.just.agentweb:agentweb:4.1.4' // (必选)
implementation 'com.just.agentweb:filechooser:4.1.4'// (可选)
implementation 'com.download.library:Downloader:4.1.4'// (可选)
implementation 'com.just.agentweb:agentweb-androidx:4.1.4' //
AgentWeb 安卓x包4.1版本1)、JAVA调用JS(数据都是虚拟生成的哦)1.搭建实体类2.准备数据源3.定义JS函数4.JAVA调用JS5.Echarts数据解析处理6.效果展示2)、JS调用JAVA1.定义需要调用的接口2.web端 JS调用JAVA3.JAVA添加JS关联4.结果展示3)、踩坑说明项目场景:问题描述:原因分析:尝试解决:
A)、依赖:
implementation 'com.just.agentweb:agentweb-androidx:4.1.4'
implementation ‘com.just.agentweb:agentweb:4.0.3-beta’
AgentWeb 源码开放地址
https://github.com/Justson/AgentWeb
效果图片,可放大,缩小(并且隐藏了原有的缩放按钮),返回,退出
下面我...
webSettings.setJavaScriptEnabled(true);
//设置适应屏幕
webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android...