Limit WebView height to screen height

pull/210/head
M66B 2 years ago
parent ae09611a2c
commit 46583b0f91

@ -23,6 +23,7 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
@ -246,7 +247,8 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Unable to create layer for WebViewEx, size 1088x16384 max size 16383 color type 4 has context 1) // Unable to create layer for WebViewEx, size 1088x16384 max size 16383 color type 4 has context 1)
int limitHeight = MeasureSpec.makeMeasureSpec(16000, MeasureSpec.AT_MOST); int h = Resources.getSystem().getDisplayMetrics().heightPixels;
int limitHeight = MeasureSpec.makeMeasureSpec(h, MeasureSpec.AT_MOST);
if (legacy) { if (legacy) {
if (height > getMinimumHeight()) if (height > getMinimumHeight())
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));

Loading…
Cancel
Save