當前位置: 首頁>>代碼示例>>Java>>正文


Java ScrollView.getScrollY方法代碼示例

本文整理匯總了Java中android.widget.ScrollView.getScrollY方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollView.getScrollY方法的具體用法?Java ScrollView.getScrollY怎麽用?Java ScrollView.getScrollY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ScrollView的用法示例。


在下文中一共展示了ScrollView.getScrollY方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: computeVerticalScrollRange

import android.widget.ScrollView; //導入方法依賴的package包/類
/**
 * Copy From ScrollView (API Level >= 14)
 * <p>The scroll range of a scroll view is the overall height of all of its
 * children.</p>
 */
private int computeVerticalScrollRange(ScrollView scrollView) {
    final int count = scrollView.getChildCount();
    final int contentHeight = scrollView.getHeight() - scrollView.getPaddingBottom() - scrollView.getPaddingTop();
    if (count == 0) {
        return contentHeight;
    }

    int scrollRange = scrollView.getChildAt(0).getBottom();
    final int scrollY = scrollView.getScrollY();
    final int overScrollBottom = Math.max(0, scrollRange - contentHeight);
    if (scrollY < 0) {
        scrollRange -= scrollY;
    } else if (scrollY > overScrollBottom) {
        scrollRange += scrollY - overScrollBottom;
    }

    return scrollRange;
}
 
開發者ID:stytooldex,項目名稱:pius1,代碼行數:24,代碼來源:SlideBottomPanel.java

示例2: testScrollToCommand

import android.widget.ScrollView; //導入方法依賴的package包/類
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  ScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollY());

  jsModule.scrollTo(0, 300);
  waitForBridgeAndUIIdle();
  getInstrumentation().waitForIdleSync();

  // Unfortunately we need to use timeouts here in order to wait for scroll animation to happen
  // there is no better way (yet) for waiting for scroll animation to finish
  long timeout = 10000;
  long interval = 50;
  long start = System.currentTimeMillis();
  while (System.currentTimeMillis() - start < timeout) {
    if (scrollView.getScrollY() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollY());
  assertFalse("Drag should not be called with scrollTo", mScrollListenerModule.dragEventsMatch());
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:29,代碼來源:ReactScrollViewTestCase.java

示例3: canChildScrollDown

import android.widget.ScrollView; //導入方法依賴的package包/類
public static boolean canChildScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            if (scrollView.getChildCount() == 0) {
                return false;
            } else {
                return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
            }
        } else {
            return false;
        }
    } else {
        return view.canScrollVertically(1);
    }
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:22,代碼來源:PtrDefaultHandler2.java

示例4: canChildPullUp

import android.widget.ScrollView; //導入方法依賴的package包/類
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;
}
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:27,代碼來源:XRefreshContentView.java

示例5: testResponderLocksScrollView

import android.widget.ScrollView; //導入方法依賴的package包/類
public void testResponderLocksScrollView() {
  ScrollView scrollView = getViewByTestId("scroll_view");
  assertNotNull(scrollView);
  assertEquals(0, scrollView.getScrollY());

  float inpx40dp = PixelUtil.toPixelFromDIP(40f);
  float inpx100dp = PixelUtil.toPixelFromDIP(100f);

  SingleTouchGestureGenerator gestureGenerator = createGestureGenerator();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture(180, 100);

  waitForBridgeAndUIIdle();

  assertTrue("Expected to scroll by at least 80 dp", scrollView.getScrollY() >= inpx100dp * .8f);

  int previousScroll = scrollView.getScrollY();

  gestureGenerator
      .startGesture(30, 30 + inpx100dp)
      .dragTo(30 + inpx40dp, 30 + inpx100dp, 10, 1200);

  waitForBridgeAndUIIdle();

  gestureGenerator
      .dragTo(30 + inpx40dp, 30, 10, 1200)
      .endGesture();

  waitForBridgeAndUIIdle();
  assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);

}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:36,代碼來源:JSResponderTestCase.java

示例6: isScrollViewToBottom

import android.widget.ScrollView; //導入方法依賴的package包/類
public static boolean isScrollViewToBottom(ScrollView scrollView) {
    if (scrollView != null) {
        int scrollContentHeight = scrollView.getScrollY() + scrollView.getMeasuredHeight() - scrollView.getPaddingTop() - scrollView.getPaddingBottom();
        int realContentHeight = scrollView.getChildAt(0).getMeasuredHeight();
        if (scrollContentHeight == realContentHeight) {
            return true;
        }
    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:BGARefreshScrollingUtil.java

示例7: onTouch

import android.widget.ScrollView; //導入方法依賴的package包/類
@Override
public boolean onTouch(View v, MotionEvent event) {
	ScrollView sv = (ScrollView) v;

	if (sv.getScrollY() == (sv.getChildAt(0).getMeasuredHeight() - sv.getMeasuredHeight()) && mCurrentViewIndex == 0){
		canPullUp = true;
	}else{
		canPullUp = false;
	}

	return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:ScrollViewContainer.java

示例8: isAtBottom

import android.widget.ScrollView; //導入方法依賴的package包/類
private boolean isAtBottom() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        return !ViewCompat.canScrollVertically(mTarget, 1);
    } else {
        if (mTarget instanceof RecyclerView) {
            return SuperSwipeHelper.isAtBottom((RecyclerView) mTarget);
        } else if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            int count = absListView.getAdapter().getCount();
            int firstPos = absListView.getFirstVisiblePosition();
            if (firstPos == 0
                    && absListView.getChildAt(0).getTop() >= absListView
                    .getPaddingTop()) {
                return false;
            }
            int lastPos = absListView.getLastVisiblePosition();
            if (lastPos > 0 && count > 0 && lastPos == count - 1) {
                return true;
            }
            return false;
        } else if (mTarget instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) mTarget;
            View view = (View) scrollView
                    .getChildAt(scrollView.getChildCount() - 1);
            if (view != null) {
                int diff = (view.getBottom() - (scrollView.getHeight() + scrollView
                        .getScrollY()));
                if (diff == 0) {
                    return true;
                }
            }
        }
        return false;
    }
}
 
開發者ID:FreeSunny,項目名稱:Amazing,代碼行數:36,代碼來源:SuperSwipeRefreshLayout.java

示例9: svPullUpIntercept

import android.widget.ScrollView; //導入方法依賴的package包/類
public boolean svPullUpIntercept(View child) {
    boolean intercept = false;
    ScrollView scrollView = (ScrollView) child;
    View scrollChild = scrollView.getChildAt(0);

    if (scrollView.getScrollY() >= (scrollChild.getHeight() - scrollView.getHeight())) {
        intercept = true;
    }
    return intercept;
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:11,代碼來源:InterceptLayout.java

示例10: getLastVisibleLine

import android.widget.ScrollView; //導入方法依賴的package包/類
public static int getLastVisibleLine(@NonNull ScrollView scrollView,
                                     int childHeight, int lineCount) {
    if (childHeight == 0) return 0;
    int line = (scrollView.getScrollY() * lineCount) / childHeight;
    if (line > lineCount) line = lineCount;
    return line;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:8,代碼來源:LineUtils.java

示例11: getFirstVisibleLine

import android.widget.ScrollView; //導入方法依賴的package包/類
public static int getFirstVisibleLine(@NonNull ScrollView scrollView, int childHeight,
                                      int lineCount) throws ArithmeticException {
    if (childHeight == 0) return 0;
    int line = (scrollView.getScrollY() * lineCount) / childHeight;
    if (line < 0) line = 0;
    return line;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:8,代碼來源:LineUtils.java

示例12: canChildScrollUp

import android.widget.ScrollView; //導入方法依賴的package包/類
/**
     * @return Whether it is possible for the child view of this layout to
     * scroll up. Override this if the child view is a custom view.
     */
    public boolean canChildScrollUp(float f) {
        boolean flag = false;

        if (!mRefreshing) {
            if (mTarget instanceof ScrollView) {

                final ScrollView scrollView = (ScrollView) mTarget;
                int scrollY = scrollView.getScrollY();
                int height = scrollView.getHeight();
                int scrollViewMeasuredHeight = scrollView.getChildAt(0).getMeasuredHeight();

//                Log.i("Test", "canChildScrollUp scrollY = " + scrollY + "| height = " + height + " | scrollViewMeasuredHeight = " + scrollViewMeasuredHeight);

                if (enabledPullDown && scrollY == 0 && f > 0) {
                    //滑動到了頂端 view.getScrollY()="+scrollY);
                    //Log.i("Test", "canChildScrollUp:" + f);
                    flag = false;
                } else if (enabledPullUp && (scrollY + height) >= scrollViewMeasuredHeight && f < 0) {
                    //滑動到了底部 scrollY="+scrollY);
                    //Log.i("Test", "canChildScrollUp:" + f);
                    flag = false;
                } else {
                    flag = true;
                }
            }
        } else {
            flag = true;
        }
        return flag;
    }
 
開發者ID:React-Native-Library,項目名稱:react-native-pull-up-down-refresh,代碼行數:35,代碼來源:RCTSwipeRefreshLayout.java

示例13: scrollOnDrag

import android.widget.ScrollView; //導入方法依賴的package包/類
private void scrollOnDrag(View view, DragEvent event, ScrollView scrollView) {
    float ty = view.getTop() + event.getY();

    if (isAncestor(scrollView, view)) {

        int thresh = scrollView.getHeight() / 6;

        if (ty < scrollView.getScrollY() + thresh) {
            scrollView.smoothScrollBy(0, -10);
        } else if (ty > scrollView.getScrollY() + scrollView.getHeight() - thresh) {
            scrollView.smoothScrollBy(0, 10);
        }
    }
}
 
開發者ID:quaap,項目名稱:LaunchTime,代碼行數:15,代碼來源:MainActivity.java

示例14: getLastVisibleLine

import android.widget.ScrollView; //導入方法依賴的package包/類
public static int getLastVisibleLine(ScrollView scrollView, int childHeight, int lineCount, int deviceHeight) {
    int line = ((scrollView.getScrollY() + deviceHeight) * lineCount) / childHeight;
    if (line > lineCount) line = lineCount;
    return line;
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:6,代碼來源:LineUtils.java


注:本文中的android.widget.ScrollView.getScrollY方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。