android.webkit.WebView#getScrollY ( )源码实例Demo

下面列出了android.webkit.WebView#getScrollY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MVPAndroidBootstrap   文件: ViewUtils.java
/**
 * Convert view to an image.  Can be used to make animations smoother.
 *
 * @param context           The current Context or Activity that this method is called from
 * @param viewToBeConverted View to convert to a Bitmap
 * @return Bitmap object that can be put in an ImageView.  Will look like the converted viewToBeConverted.
 */
public static Bitmap viewToImage(Context context, WebView viewToBeConverted) {
    int extraSpace = 2000; //because getContentHeight doesn't always return the full screen height.
    int height = viewToBeConverted.getContentHeight() + extraSpace;

    Bitmap viewBitmap = Bitmap.createBitmap(viewToBeConverted.getWidth(), height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(viewBitmap);
    viewToBeConverted.draw(canvas);

    //If the view is scrolled, cut off the top part that is off the screen.
    try {
        int scrollY = viewToBeConverted.getScrollY();
        if (scrollY > 0) {
            viewBitmap = Bitmap.createBitmap(viewBitmap, 0, scrollY, viewToBeConverted.getWidth(), height - scrollY);
        }
    } catch (Exception ex) {
        Log.e("PercolateAndroidUtils", "Could not remove top part of the webview image.  ex=" + ex);
    }

    return viewBitmap;
}
 
源代码2 项目: RxAndroidBootstrap   文件: ViewUtils.java
/**
 * Convert view to an image.  Can be used to make animations smoother.
 *
 * @param context           The current Context or Activity that this method is called from
 * @param viewToBeConverted View to convert to a Bitmap
 * @return Bitmap object that can be put in an ImageView.  Will look like the converted viewToBeConverted.
 */
public static Bitmap viewToImage(Context context, WebView viewToBeConverted) {
    int extraSpace = 2000; //because getContentHeight doesn't always return the full screen height.
    int height = viewToBeConverted.getContentHeight() + extraSpace;

    Bitmap viewBitmap = Bitmap.createBitmap(viewToBeConverted.getWidth(), height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(viewBitmap);
    viewToBeConverted.draw(canvas);

    //If the view is scrolled, cut off the top part that is off the screen.
    try {
        int scrollY = viewToBeConverted.getScrollY();
        if (scrollY > 0) {
            viewBitmap = Bitmap.createBitmap(viewBitmap, 0, scrollY, viewToBeConverted.getWidth(), height - scrollY);
        }
    } catch (Exception ex) {
        Log.e("PercolateAndroidUtils", "Could not remove top part of the webview image.  ex=" + ex);
    }

    return viewBitmap;
}
 
源代码3 项目: caffeine   文件: ViewUtils.java
/**
 * Convert view to an image.  Can be used to make animations smoother.
 *
 * @param context           The current Context or Activity that this method is called from.
 * @param viewToBeConverted View to convert to a Bitmap.
 * @return Bitmap object that can be put in an ImageView.  Will look like the converted viewToBeConverted.
 */
public static Bitmap viewToImage(Context context, WebView viewToBeConverted) {
    int extraSpace = 2000; //because getContentHeight doesn't always return the full screen height.
    int height = viewToBeConverted.getContentHeight() + extraSpace;

    Bitmap viewBitmap = Bitmap.createBitmap(viewToBeConverted.getWidth(), height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(viewBitmap);
    viewToBeConverted.draw(canvas);

    //If the view is scrolled, cut off the top part that is off the screen.
    try {
        int scrollY = viewToBeConverted.getScrollY();
        if (scrollY > 0) {
            viewBitmap = Bitmap.createBitmap(viewBitmap, 0, scrollY, viewToBeConverted.getWidth(), height - scrollY);
        }
    } catch (Exception ex) {
        Log.e("Caffeine", "Could not remove top part of the webview image.  ex=" + ex);
    }

    return viewBitmap;
}
 
/**
 * 规避 contentHeight 异步变化
 * @return
 */
private boolean canWebViewScrollUp(WebView webView) {
    if (mWebViewContentHeight == 0) {
        mWebViewContentHeight = (int) (webView.getContentHeight() * webView.getScale());
    }
    final int offset = webView.getScrollY();
    final int range = mWebViewContentHeight - webView.getHeight();
    if (range == 0) {
        return false;
    }
    return offset > 2;
}
 
/**
 * 规避 contentHeight 异步变化
 * @return
 */
private boolean canWebViewScrollDown(WebView webView) {
    if (mWebViewContentHeight == 0) {
        mWebViewContentHeight = (int) (webView.getContentHeight() * webView.getScale());
    }
    final int offset = webView.getScrollY();
    final int range = mWebViewContentHeight - webView.getHeight();
    if (range == 0) {
        return false;
    }
    return offset < range - 2;
}
 
源代码6 项目: RichWebList   文件: HeaderScrollHelper.java
private boolean isWebViewTop(WebView scrollView) {
    if (scrollView != null) {
        int scrollViewY = scrollView.getScrollY();
        return scrollViewY <= 0;
    }
    return false;
}
 
源代码7 项目: DanDanPlayForAndroid   文件: ScrollableHelper.java
private static boolean isWebViewTop(WebView scrollView) {
    if (scrollView != null) {
        int scrollViewY = scrollView.getScrollY();
        return scrollViewY <= 0;
    }
    return false;
}
 
源代码8 项目: talk-android   文件: MDRootLayout.java
private void invalidateDividersForWebView(WebView view, final boolean setForTop, boolean setForBottom, boolean hasButtons) {
    if (setForTop) {
        mDrawTopDivider = mTitleBar != null &&
                mTitleBar.getVisibility() != View.GONE &&
                //Not scrolled to the top.
                view.getScrollY() + view.getPaddingTop() > 0;
    }
    if (setForBottom) {
        //noinspection deprecation
        mDrawBottomDivider = hasButtons &&
                view.getScrollY() + view.getMeasuredHeight() - view.getPaddingBottom() < view.getContentHeight() * view.getScale();
    }
}
 
源代码9 项目: ScrollableLayout   文件: ScrollableHelper.java
private static boolean isWebViewTop(WebView scrollView) {
    if (scrollView != null) {
        int scrollViewY = scrollView.getScrollY();
        return scrollViewY <= 0;
    }
    return false;
}
 
源代码10 项目: ScrollableLayout   文件: ScrollableHelper.java
private static boolean isWebViewTop(WebView scrollView){
    if(scrollView != null) {
        int scrollViewY = scrollView.getScrollY();
        return scrollViewY <= 0;
    }
    return false;
}
 
源代码11 项目: AgentWebX5   文件: ScrollingUtil.java
public static boolean isWebViewToBottom(WebView webview, int mTouchSlop) {
    return webview != null && ((webview.getContentHeight() * webview.getScale() - (webview.getHeight() + webview.getScrollY())) <= 2 * mTouchSlop);
}
 
源代码12 项目: TwinklingRefreshLayout   文件: ScrollingUtil.java
public static boolean isWebViewToBottom(WebView webview, int mTouchSlop) {
    return webview != null && ((webview.getContentHeight() * webview.getScale() - (webview.getHeight() + webview.getScrollY())) <= 2 * mTouchSlop);
}
 
源代码13 项目: AndroidStudyDemo   文件: BGAScrollingUtil.java
public static boolean isWebViewToBottom(WebView webView) {
    return webView != null && webView.getContentHeight() * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight());
}
 
源代码14 项目: Pas   文件: ScrollingUtil.java
public static boolean isWebViewToBottom(WebView webView) {
    return webView != null && webView.getContentHeight() * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight());
}