当前位置: 首页>>代码示例>>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;未经允许,请勿转载。