Created
February 7, 2020 07:54
-
-
Save pyeongho/70dc3d9c1035a9082756f7982059876a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
public class LollipopFixedWebViewJ extends WebView { | |
public LollipopFixedWebViewJ(Context context) { | |
super(getFixedContext(context)); | |
} | |
public LollipopFixedWebViewJ(Context context, AttributeSet attrs) { | |
super(getFixedContext(context), attrs); | |
} | |
public LollipopFixedWebViewJ(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(getFixedContext(context), attrs, defStyleAttr); | |
} | |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
public LollipopFixedWebViewJ(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | |
super(getFixedContext(context), attrs, defStyleAttr, defStyleRes); | |
} | |
private 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment