public class MyWebView extends WebView {
public MyWebView(Context context) {
super(getFixedContext(context));
}
public MyWebView(Context context, AttributeSet attrs) {
super(getFixedContext(context), attrs);
}
public MyWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(getFixedContext(context), attrs, defStyleAttr);
}
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;
}
}
网友评论