Advertisement
retnet

lolipop webview activity/fragment

May 18th, 2020
1,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package com.nama.paket.apkmu;
  2.  
  3. import android.annotation.SuppressLint;
  4. import android.content.Context;
  5. import android.content.res.Configuration;
  6. import android.os.Build;
  7. import android.util.AttributeSet;
  8. import android.webkit.WebView;
  9.  
  10. public class LollipopFixedWebView extends WebView {
  11.     public LollipopFixedWebView(Context context) {
  12.         super(getFixedContext(context));
  13.     }
  14.     public LollipopFixedWebView(Context context, AttributeSet attrs) {
  15.         super(getFixedContext(context), attrs);
  16.     }
  17.     public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
  18.         super(getFixedContext(context), attrs, defStyleAttr);
  19.     }
  20.     @SuppressLint("NewApi")
  21.     private static Context getFixedContext(Context context) {
  22.         if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) // Android Lollipop 5.0 & 5.1
  23.             return context.createConfigurationContext(new Configuration());
  24.         return context;
  25.     }
  26. }
  27. /*
  28. // letakkan di layout sesuaikan nama paketnya
  29. <com.nama.paket.apkmu.LollipopFixedWebView
  30. android:id="@+id/webview"
  31. android:layout_width="match_parent"
  32. android:layout_height="match_parent"/>
  33. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement