美文网首页
Android5.x中WebView报错 Error infla

Android5.x中WebView报错 Error infla

作者: 雨田Android开发 | 来源:发表于2021-01-08 15:03 被阅读0次
    public class LollipopFixedWebView extends WebView {
    
        public LollipopFixedWebView(Context context) {
            super(getFixedContext(context));
        }
    
        public LollipopFixedWebView(Context context, AttributeSet attrs) {
            super(getFixedContext(context), attrs);
        }
    
        public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
            super(getFixedContext(context), attrs, defStyleAttr);
        }
    
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
        }
    
        public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
            super(getFixedContext(context), attrs, defStyleAttr, privateBrowsing);
        }
    
        public static Context getFixedContext(Context context) {
            if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) // Android Lollipop 5.0 & 5.1
                return context.createConfigurationContext(new Configuration());
            return context;
        }
    }
    

    相关文章

      网友评论

          本文标题:Android5.x中WebView报错 Error infla

          本文链接:https://www.haomeiwen.com/subject/cylfaktx.html