/** * Returns true if the view is sufficiently shown * * @param view the view to check * @return true if the view is sufficiently shown */ public final boolean isWebElementSufficientlyShown(WebElement webElement){ final WebView webView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class, true)); final int[] xyWebView = new int[2]; if(webView != null && webElement != null){ webView.getLocationOnScreen(xyWebView); if(xyWebView[1] + webView.getHeight() > webElement.getLocationY()) return true; } return false; }
try { final Bitmap bmp = Bitmap.createBitmap(webView.getWidth(), webView.getHeight(), Bitmap.Config.ARGB_8888); final Canvas c = new Canvas(bmp); webView.draw(c);
mWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { // Column Count is just the number of 'screens' of text. Add one for partial 'screens' int columnCount = Math.floor(view.getHeight() / view.getWidth())+1; // Must be expressed as a percentage. If not set then the WebView will not stretch to give the desired effect. int columnWidth = columnCount * 100; String js = "var d = document.getElementsByTagName('body')[0];" + "d.style.WebkitColumnCount=" + columnCount + ";" + "d.style.WebkitColumnWidth='" + columnWidth + "%';"; mWebView.loadUrl("javascript:(function(){" + js + "})()"); } }); mWebView.loadUrl("file:///android_asset/chapter.xml");
@Override protected boolean isReadyForPullEnd() { double exactContentHeight = Math.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
public boolean canChildPullUp() { if (child instanceof AbsListView) { AbsListView absListView = (AbsListView) child; return canScrollVertically(child, 1) || absListView.getLastVisiblePosition() != mTotalItemCount - 1; } else if (child instanceof WebView) { WebView webview = (WebView) child; if (webview instanceof XWebView) { return !((XWebView) webview).isBottom(); } else { float left = webview.getContentHeight() * webview.getScale(); int right = webview.getHeight() + webview.getScrollY(); return left != right; } } else if (child instanceof ScrollView) { ScrollView scrollView = (ScrollView) child; View childView = scrollView.getChildAt(0); if (childView != null) { return canScrollVertically(child, 1) || scrollView.getScrollY() < childView.getHeight() - scrollView.getHeight(); } } else { return canScrollVertically(child, 1); } return true; }
public void _dropText(WebView wv, String text, float x, float y) { wv.loadUrl("javascript:dropText('" + text + "', " + x + ", " + y + ", " + wv.getHeight() + ", " + wv.getWidth() + ")"); }
web.setPictureListener(new WebView.PictureListener() { public void onNewPicture(WebView view, Picture picture) { float temp = (float) view.getHeight(); height = view.getContentHeight() * a; } });
private float convertWebViewToScreenY(float y) { return y * this.webView.getHeight() / this.webView.getContentHeight(); }
private WebView mWebView; public void onSavePhoto(int top, int left, int width, int height){ Bitmap bitmap = Bitmap.createBitmap(mWebView.getWidth(), mWebView.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); mWebView.draw(canvas); // crop bitmap: Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, left, top, width, height); }
class WebViewUtil { public static void scaleTo(WebView view, Int size) { double currentHeight = view.getHeight(); double currentWidth = view.getWidth(); double scaleX = size / currentWidth; double scaleY = size / currentHeight; double scale = Math.min(scaleX, scaleY); view.scaleX(scale); view.scaleY(scale); } }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = (float) Math.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = (float) Math.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }
@Override protected boolean isReadyForPullEnd() { float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); }