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

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

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

ScrollView.smoothScrollTo介绍

暂无

代码示例

代码示例来源:origin: TommyLemon/Android-ZBLibrary

@Override
  public void run() {
    dismissProgressDialog();
    tvDemoSQLShow0.setText("" + s0);
    tvDemoSQLShow1.setText("" + s1);
    svDemoSQL.smoothScrollTo(0, 0);
  }
});

代码示例来源:origin: TommyLemon/Android-ZBLibrary

/**显示图片
 * @param path
 */
private void setPicture(String path) {
  if (StringUtil.isFilePath(path) == false) {
    Log.e(TAG, "setPicture  StringUtil.isFilePath(path) == false >> showShortToast(找不到图片);return;");
    showShortToast("找不到图片");
    return;
  }
  this.picturePath = path;
  svDemoMain.smoothScrollTo(0, 0);
  Glide.with(context).load(path).into(ivDemoMainHead);
}

代码示例来源:origin: TommyLemon/Android-ZBLibrary

case REQUEST_TO_EDIT_TEXT_INFO:
  if (data != null) {
    svDemoMain.smoothScrollTo(0, 0);
    tvDemoMainHeadName.setText(StringUtil.getTrimedString(
        data.getStringExtra(EditTextInfoWindow.RESULT_VALUE)));

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

ScrollView scrollView = (ScrollView)getView().findViewById(scrollID);
scrollView.post(new Runnable() {

  @Override
  public void run() {
    scrollView.smoothScrollTo(0,(getView().findViewById(relativeID)).getTop());
  }
});

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

@Test
public void shouldSmoothScrollTo() throws Exception {
 ScrollView scrollView = new ScrollView(ApplicationProvider.getApplicationContext());
 scrollView.smoothScrollTo(7, 6);
 assertEquals(7, scrollView.getScrollX());
 assertEquals(6, scrollView.getScrollY());
}

代码示例来源: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: wallabag/android-app

@Override
  public void run() {
    scrollView.smoothScrollTo(0, (int) textItem.top);
  }
});

代码示例来源:origin: Shuyun123/MenuSummary

/**
 * 改变左侧栏选中项的位置
 *
 * @param clickPosition
 */
private void changeTextLocation(int clickPosition) {
  // 获得点击的view视图距离屏幕顶部的距离
  int y = (views[clickPosition].getTop());
  // 如果滑动条可以滑动的情况下就把点击的视图移动到顶部
  scrollView.smoothScrollTo(0, y);
}

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

et_email.setOnTouchListener(new View.OnTouchListener() {
   @Override
   public boolean onTouch(View v, MotionEvent event) {
     if (MotionEvent.ACTION_DOWN == event.getAction()) {
       ScrollView scrollView = (ScrollView)getView().findViewById(R.id.ScrollViewSendDetails);
       scrollView.smoothScrollTo(0, 500);
     }
     return false;
   }
 });

代码示例来源:origin: envyfan/AndroidReview

public void run() {
    if (scroll == null || inner == null) {
      return;
    }
    int offset = inner.getMeasuredHeight() - scroll.getHeight();
    if (offset < 0) {
      offset = 0;
    }
    scroll.smoothScrollTo(0, offset);
  }
});

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

ScrollView scrollView=(ScrollView) findViewById(R.id.sc);
   scrollView.post(new Runnable() {
     public void run() {
       scrollView.smoothScrollTo(0, scrollView.getBottom());
     }
   });

代码示例来源:origin: baidu/speech-samples

private void print(String msg) {
    txtLog.append(msg + "\n");
    ScrollView sv = (ScrollView) txtLog.getParent();
    sv.smoothScrollTo(0, 1000000);
    Log.d(TAG, "----" + msg);
  }
}

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

final ScrollView sv = (ScrollView) findViewById(R.id.scrollView1);
TableLayout tl = (TableLayout) findViewById(R.id.arrivalstable);
int index = 40;
final View child = tl.getChildAt(index);
new Handler().post(new Runnable() {
  @Override
  public void run() {
    sv.smoothScrollTo(0, child.getBottom());
  }
});

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

final View rootView = inflater.inflate(R.layout.fragment_snakes, container, false);
Button button = (Button) rootView.findViewById(R.id.Button1);
TextView paragraph1 = (TextView) rootView.findViewById(R.id.TextView1);
ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.ScrollView);
button.setOnClickListener(new OnClickListener() {
  public void onClick(final View v) {
    scrollView.smoothScrollTo(0,paragraph1.getTop());
  }
});

代码示例来源:origin: baidu/speech-samples

private void print(String msg) {
    txtLog.append(msg + "\n");
    ScrollView sv = (ScrollView) txtLog.getParent();
    sv.smoothScrollTo(0, 1000000);
    Log.d(TAG, "----" + msg);
  }
}

代码示例来源: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).smoothScrollTo(Integer.parseInt(list.get(0)), Integer.parseInt(list.get(1)));
  }
}

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

ScrollView mScrollView = (ScrollView) findViewById(R.id.scroll_view);
mScrollView.post(new Runnable() {
  public void run() { 
    Button btn = (Button) findViewById(k); 
    ViewGroup vg =(ViewGroup)btn.getParent();
    mScrollView.smoothScrollTo(0,vg.getTop());
   }});
}

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

ScrollView scrollView=(ScrollView) findViewById(R.id.sc);
Button button=(Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
      scrollView.post(new Runnable() {

    public void run() {
      scrollView.smoothScrollTo(0, scrollView.getBottom());
    }
  });
    }
  });

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

public static void bringPointIntoView (TextView textView,
ScrollView scrollView, int offset)
{
 int line = textView.getLayout ().getLineForOffset (offset);
 int y = (int) ((line + 0.5) * textView.getLineHeight ());
 scrollView.smoothScrollTo (0, y - scrollView.getHeight () / 2);
}

代码示例来源:origin: Calsign/APDE

public void scrollToChar(int pos, EditorActivity editor) {
  float xOffset = getCompoundPaddingLeft();
  
  //Calculate coordinates
  int x = (int) Math.max(xOffset + getLayout().getPrimaryHorizontal(pos), 1);
  int y = getLineHeight() * getLayout().getLineForOffset(pos);
  
  ((HorizontalScrollView) editor.findViewById(R.id.code_scroller_x)).smoothScrollTo(x, 0);
  ((ScrollView) editor.findViewById(R.id.code_scroller)).smoothScrollTo(0, y);
}

相关文章

ScrollView类方法