From 2b583cff1c0d66adeb04013e652c45a977956cd2 Mon Sep 17 00:00:00 2001 From: Ztiany Date: Wed, 18 Dec 2019 17:52:33 +0800 Subject: [PATCH] add LollipopFixedWebView --- .../widget/compat/LollipopFixedWebView.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib_base/src/main/java/com/android/base/widget/compat/LollipopFixedWebView.java diff --git a/lib_base/src/main/java/com/android/base/widget/compat/LollipopFixedWebView.java b/lib_base/src/main/java/com/android/base/widget/compat/LollipopFixedWebView.java new file mode 100644 index 0000000..c81895b --- /dev/null +++ b/lib_base/src/main/java/com/android/base/widget/compat/LollipopFixedWebView.java @@ -0,0 +1,40 @@ +package com.android.base.widget.compat; + +import android.annotation.TargetApi; +import android.content.Context; +import android.content.res.Configuration; +import android.os.Build; +import android.util.AttributeSet; +import android.webkit.WebView; + +/** + * @see android-view-inflateexception-error-inflating-class-android-webkit-webview + */ +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) { + return context.createConfigurationContext(new Configuration()); + } + +} \ No newline at end of file