Example usage for android.webkit WebView getMeasuredHeight

List of usage examples for android.webkit WebView getMeasuredHeight

Introduction

In this page you can find the example usage for android.webkit WebView getMeasuredHeight.

Prototype

public final int getMeasuredHeight() 

Source Link

Document

Like #getMeasuredHeightAndState() , but only returns the raw height component (that is the result is masked by #MEASURED_SIZE_MASK ).

Usage

From source file:cn.bingoogolapple.refreshlayout.util.BGARefreshScrollingUtil.java

public static boolean isWebViewToBottom(WebView webView) {
    return webView != null && webView.getContentHeight()
            * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight());
}

From source file:com.lanma.customviewproject.utils.ScrollingUtil.java

/**
 * webView?//from  w w  w  .  j  a v a  2  s  . c o  m
 */
public static boolean isWebViewToBottom(WebView webView) {
    return webView != null && webView.getContentHeight()
            * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight());
}

From source file:net.gsantner.opoc.util.ShareUtil.java

/**
 * Create a picture out of {@link WebView}'s whole content
 *
 * @param webView The WebView to get contents from
 * @return A {@link Bitmap} or null//  w  w  w  .ja  v a  2s.c o m
 */
@Nullable
public static Bitmap getBitmapFromWebView(WebView webView) {
    try {
        //Measure WebView's content
        int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED,
                View.MeasureSpec.UNSPECIFIED);
        int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        webView.measure(widthMeasureSpec, heightMeasureSpec);
        webView.layout(0, 0, webView.getMeasuredWidth(), webView.getMeasuredHeight());

        //Build drawing cache and store its size
        webView.buildDrawingCache();
        int measuredWidth = webView.getMeasuredWidth();
        int measuredHeight = webView.getMeasuredHeight();

        //Creates the bitmap and draw WebView's content on in
        Bitmap bitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.drawBitmap(bitmap, 0, bitmap.getHeight(), new Paint());

        webView.draw(canvas);
        webView.destroyDrawingCache();

        return bitmap;
    } catch (Exception | OutOfMemoryError e) {
        e.printStackTrace();
        return null;
    }
}