android.widget.ScrollView.smoothScrollBy()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中android.widget.ScrollView.smoothScrollBy()方法的一些代码示例,展示了ScrollView.smoothScrollBy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollView.smoothScrollBy()方法的具体详情如下:
包路径:android.widget.ScrollView
类名称:ScrollView
方法名:smoothScrollBy

ScrollView.smoothScrollBy介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
 public void shouldSmoothScrollBy() throws Exception {
  ScrollView scrollView = new ScrollView(ApplicationProvider.getApplicationContext());
  scrollView.smoothScrollTo(7, 6);
  scrollView.smoothScrollBy(10, 20);

  assertEquals(17, scrollView.getScrollX());
  assertEquals(26, scrollView.getScrollY());
 }
}

代码示例来源:origin: stackoverflow.com

/* recently_added_textview being the TextView that was added to trigger this */
ScrollView my_scrollview = (ScrollView) findViewById(R.id.scroller);
int height = recently_added_textview.getHeight();
my_scrollview.smoothScrollBy(0, height);
/* x being 0 assuming you don't want to scroll left and right */

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    List<String> list = RapidStringUtils.stringToList(value.getString());
    if( list.size() < 2 ){
      return;
    }
    ((ScrollView)view).smoothScrollBy(Integer.parseInt(list.get(0)), Integer.parseInt(list.get(1)));
  }
}

代码示例来源:origin: IndoorAtlas/android-sdk-examples

/**
 * Append message into log prefixing with duration since start of location requests.
 */
private void log(String msg) {
  double duration = mRequestStartTime != 0
      ? (SystemClock.elapsedRealtime() - mRequestStartTime) / 1e3
      : 0d;
  mLog.append(String.format(Locale.US, "\n[%06.2f]: %s", duration, msg));
  mScrollView.smoothScrollBy(0, mLog.getBottom());
}

代码示例来源:origin: federicoiosue/checklistview

@Override
  public void run() {
    int scrollStep = dragDirection == DIRECTION_UP ? -Constants.SCROLLING_STEP : Constants.SCROLLING_STEP;
    while (scroll) {
      scrollView.smoothScrollBy(0, DensityUtil.dpToPx(scrollStep, scrollView.getContext()));
      try {
        Thread.sleep(Constants.SCROLLING_DELAY);
      } catch (InterruptedException e) {
        Log.d(TAG, "InterruptedException");
      }
    }
  }
}

代码示例来源:origin: IndoorAtlas/android-sdk-examples

/**
 * Append message into log prefixing with duration since start of location requests.
 */
private void log(String msg) {
  double duration = mRequestStartTime != 0
      ? (SystemClock.elapsedRealtime() - mRequestStartTime) / 1e3
      : 0d;
  mLog.append(String.format(Locale.US, "\n[%06.2f]: %s", duration, msg));
  mScrollView.smoothScrollBy(0, mLog.getBottom());
}

代码示例来源: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: stackoverflow.com

mainScrollView.smoothScrollBy(0, 30);
mainScrollView.smoothScrollBy(0, -30);

代码示例来源:origin: quaap/LaunchTime

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);
    }
  }
}

代码示例来源:origin: stackoverflow.com

mScrollView.smoothScrollBy(0, 6);
mScrollView.smoothScrollBy(0, -6);

代码示例来源:origin: stackoverflow.com

final TextView tv=(TextView)findViewById(R.id.lyrics);
 final ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView1);
 Button start = (Button) findViewById(R.id.button_start);
 Button stop = (Button) findViewById(R.id.button_stop);
 final Handler timerHandler = new Handler();
 final Runnable timerRunnable = new Runnable() {
   @Override
   public void run() {
     scrollView.smoothScrollBy(0,5);         // 5 is how many pixels you want it to scroll vertically by
     timerHandler.postDelayed(this, 10);     // 10 is how many milliseconds you want this thread to run
   }
 };
 start.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
     timerHandler.postDelayed(timerRunnable, 0);
   }
 });
 stop.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
     timerHandler.removeCallbacks(timerRunnable);
   }
 });

代码示例来源:origin: stackoverflow.com

final TextView tv=(TextView)findViewById(R.id.lyrics);
 final ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView1);
 Button start = (Button) findViewById(R.id.button_start);
 Button stop = (Button) findViewById(R.id.button_stop);
 final Handler timerHandler = new Handler();
 final Runnable timerRunnable = new Runnable() {
   @Override
   public void run() {
     scrollView.smoothScrollBy(0,5);         // 5 is how many pixels you want it to scroll vertically by
     timerHandler.postDelayed(this, 10);     // 10 is how many milliseconds you want this thread to run
   }
 };
 start.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
     timerHandler.postDelayed(timerRunnable, 0);
   }
 });
 stop.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
     timerHandler.removeCallbacks(timerRunnable);
   }
 });

代码示例来源:origin: stackoverflow.com

private ScrollView _scrollView;

private Runnable _smoothScrollRunnable = new Runnable() {
  @Override
  public void run() {
    _scrollView.smoothScrollBy(2, 2);

    if (_scrollView.canScrollVertically(1)) {
      _scrollView.postDelayed(_smoothScrollRunnable, 75);
    }
  }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  _scrollView = (ScrollView) findViewById(R.id.scrollview);
}

@Override
protected void onResume() {
  super.onResume();

  _scrollView.post(_smoothScrollRunnable);
}

代码示例来源:origin: jakebonk/BoardView

parent.getLocationOnScreen(parentLocation);
if(mLastEventY < parentLocation[1]+200){
  parent.smoothScrollBy(0,-10);
  parent.smoothScrollBy(0,10);

代码示例来源:origin: jakebonk/DraggableTreeView

mRootLayout.getLocationOnScreen(root_location);
if(root_location[1] > mLastEventY - dpToPx(25)){
  mRootLayout.smoothScrollBy(0,-10);
  mRootLayout.smoothScrollBy(0,10);

代码示例来源:origin: stackoverflow.com

sv.smoothScrollBy(0, scrollYDelta);
break;

相关文章

ScrollView类方法