admin管理员组文章数量:1558087
低版本Vivo 5.1 webView适配问题!!!
前几天用户说自己手机进不去应用 问了手机型号和Android版本号,手机是vivo x7 Android版本号是 5.1.
因为我们一进去是WebView界面然后就开始找问题 我觉得就是我这边适配的问题 然后看见网上说是需要自定义View 重写一些方法 代码如下在这里插入代码片
public class VivoWeb extends WebView {
public VivoWeb(Context context) {
super(getFixedContext(context));
}
public VivoWeb(Context context, AttributeSet attrs) {
super(getFixedContext(context), attrs);
}
public VivoWeb(Context context, AttributeSet attrs, int defStyleAttr) {
super(getFixedContext(context), attrs, defStyleAttr);
}
// To fix Android Lollipop WebView problem create a new configuration on that Android version only
private static Context getFixedContext(Context context) {
if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) // Android Lollipop 5.0 & 5.1
return context.createConfigurationContext(new Configuration());
return context;
}
然后在你的xml控件上用上这个类,当然在你用到的Activity里面也改成这个。
//解决Vivo5.1webView适配问题
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
这个依赖呢是 为了适配用的 在这里也是犯了个错误 我门项目比较老 是 support库,但是我导入了Androidx的依赖 导致无法运行 后来我把项目全部转换成Androidx的了。support库和Androidx的依赖不能共同使用 如果不想转 网上也有support和Androidx对应的依赖
具体转换网上搜把 一大片
Android适配到这边基本也就完事了 ,但是呢我这边依然不行 后来查阅资料发现H5那边也是需要适配的,如果你到这里还没有好的话你问下H5同时项目是用的 es6 写的 还是es5写的,es6 Android安卓低版本是不支持的。
H5同事改完之后就可以进去了 我这边就是这样的情况
版权声明:本文标题:Android低版本Vivo 5.1 webView适配问题!!! 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1727360526a1110551.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论