本文整理了Java中android.view.View.scrollBy()
方法的一些代码示例,展示了View.scrollBy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。View.scrollBy()
方法的具体详情如下:
包路径:android.view.View
类名称:View
方法名:scrollBy
暂无
代码示例来源:origin: RobotiumTech/robotium
public void run(){
view.scrollBy(0, scrollAmount);
}
});
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (int) animation.getAnimatedValue();
try {
if (mScrollableView instanceof AbsListView) {
scrollListBy((AbsListView) mScrollableView, value - mLastSpinner);
} else {
mScrollableView.scrollBy(value - mLastSpinner, 0);
}
} catch (Throwable ignored) {
//根据用户反馈,此处可能会有BUG
}
mLastSpinner = value;
}
}
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int value = (int) animation.getAnimatedValue();
try {
if (mScrollableView instanceof AbsListView) {
scrollListBy((AbsListView) mScrollableView, value - mLastSpinner);
} else {
mScrollableView.scrollBy(0, value - mLastSpinner);
}
} catch (Throwable ignored) {
//根据用户反馈,此处可能会有BUG
}
mLastSpinner = value;
}
//</editor-fold>
代码示例来源:origin: Cleveroad/AdaptiveTableLayout
@Override
public void run() {
// scroll speed. Calculated by hand.
int shiftDistanceX = mDiffX / 5;
int shiftDistanceY = mDiffY / 5;
if ((shiftDistanceX != 0 || shiftDistanceY != 0) && !isFinished) {
// change state
isFinished = false;
// scroll view
mView.scrollBy(shiftDistanceX, shiftDistanceY);
// start self again
mView.post(this);
} else {
// have no shift distance or need to finish.
stop();
}
}
代码示例来源:origin: Cleveroad/AdaptiveTableLayout
@Override
public void run() {
if (mScroller.isFinished()) {
return;
}
// calculate offset
boolean more = mScroller.computeScrollOffset();
int x = mScroller.getCurrX();
int y = mScroller.getCurrY();
int diffX = mLastX - x;
int diffY = mLastY - y;
if (diffX != 0 || diffY != 0) {
mView.scrollBy(diffX, diffY);
mLastX = x;
mLastY = y;
}
if (more) {
// run self
mView.post(this);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void scrollBy_shouldStoreTheScrolledCoordinates() throws Exception {
view.scrollTo(4, 5);
view.scrollBy(10, 20);
assertThat(shadowOf(view).scrollToCoordinates).isEqualTo(new Point(14, 25));
assertThat(view.getScrollX()).isEqualTo(14);
assertThat(view.getScrollY()).isEqualTo(25);
}
代码示例来源:origin: GeekGhost/Ghost
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
int moveX = (int) event.getRawX();
int deltaX = tempX - moveX;
tempX = moveX;
if (moveX - downX > mTouchSlop
&& Math.abs((int) event.getRawY() - downY) < mTouchSlop) {
isSilding = true;
}
if (moveX - downX >= 0 && isSilding) {
mContentView.scrollBy(deltaX, 0);
}
break;
case MotionEvent.ACTION_UP:
isSilding = false;
if (mContentView.getScrollX() <= -viewWidth / 2) {
isFinish = true;
scrollRight();
} else {
scrollOrigin();
isFinish = false;
}
break;
}
return true;
}
代码示例来源:origin: huxq17/XRefreshView
itemView.scrollBy(deltaX, 0);
break;
case MotionEvent.ACTION_UP:
代码示例来源:origin: zhuanghongji/custom-android-keyboard
@Override
public void onDismiss() {
if (mScrollDistance > 0) {
int temp = mScrollDistance;
mScrollDistance = 0;
if (null != mContentView) {
mContentView.scrollBy(0, -temp);
}
}
}
});
代码示例来源:origin: luili16/UIMocker
public void run() {
view.scrollBy(0, scrollAmount);
}
});
代码示例来源:origin: com.jayway.android.robotium/robotium-solo
public void run(){
view.scrollBy(0, scrollAmount);
}
});
代码示例来源:origin: luili16/UIMocker
@Override
public void run() {
view.scrollBy(scrollAmount, 0);
}
});
代码示例来源:origin: 543441727/DragRecyclerView
/**
* 向右滑动
*/
private void scrollRight(View item, int scorllX){
Log.e(TAG, " scroll right -> " + scorllX);
item.scrollBy(scorllX, 0);
}
代码示例来源:origin: 543441727/DragRecyclerView
/**
* 向左滑动
*/
private void scrollLeft(View item, int scorllX){
Log.e(TAG, " scroll left -> " + scorllX);
item.scrollBy(scorllX, 0);
}
代码示例来源:origin: SilenceDut/ExpandableLayout
@Override
public void onAnimationUpdate(ValueAnimator animation) {
dy = (int)animation.getAnimatedValue()-lastDy;
lastDy = (int)animation.getAnimatedValue();
parent.scrollBy(0,dy);
}
});
代码示例来源:origin: BoBoMEe/Android-Demos
@OnClick({ R.id.btn_scroll_to, R.id.btn_scroll_by }) public void setBtnScroll(View view) {
switch (view.getId()) {
case R.id.btn_scroll_to:
mScrollLayout.scrollTo(DISTANCE_X, DISTANCE_Y);
break;
case R.id.btn_scroll_by:
mScrollLayout.scrollBy(DISTANCE_X, DISTANCE_Y);
break;
}
}
}
代码示例来源:origin: linxin6560/DetailScrollView
@Override
public void customScrollBy(int dy) {
getView().scrollBy(0, dy);
}
代码示例来源:origin: stackoverflow.com
@Override
public void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
final View viewAbove = getSlidingMenu().mViewAbove;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
viewAbove.scrollBy(-60, 0);
}
}, 500);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
viewAbove.scrollBy(60, 0);
}
}, 2000);
}
代码示例来源:origin: Justson/AgentWebX5
public static void scrollAViewBy(View view, int height) {
if (view instanceof RecyclerView) ((RecyclerView) view).scrollBy(0, height);
else if (view instanceof ScrollView) ((ScrollView) view).smoothScrollBy(0, height);
else if (view instanceof AbsListView) ((AbsListView) view).smoothScrollBy(height, 0);
else {
try {
Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class);
method.invoke(view, 0, height);
} catch (Exception e) {
view.scrollBy(0, height);
}
}
}
代码示例来源:origin: nenick/espresso-macchiato
@Override
public void run() {
getActivity().findViewById(LongListActivity.listViewId).scrollBy(0, distance);
}
});
内容来源于网络,如有侵权,请联系作者删除!