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

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

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

ScrollView.getScrollX介绍

暂无

代码示例

代码示例来源: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: chaychan/TouTiao

mNestedScrollView.scrollTo(mNestedScrollView.getScrollX(), 0);

代码示例来源:origin: wallabag/android-app

private void restoreReadingPosition() {
  Log.d(TAG, "restoreReadingPosition() articleProgress: " + articleProgress);
  if(articleProgress != null) {
    int viewHeight = scrollView.getHeight();
    int totalHeight = scrollView.getChildAt(0).getHeight();
    Log.v(TAG, "restoreReadingPosition() viewHeight: " + viewHeight
        + ", totalHeight: " + totalHeight);
    totalHeight -= viewHeight;
    int yOffset = totalHeight > 0 ? ((int)Math.round(articleProgress * totalHeight)) : 0;
    Log.v(TAG, "restoreReadingPosition() yOffset: " + yOffset);
    scrollView.scrollTo(scrollView.getScrollX(), yOffset);
  }
}

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

ScrollView sv1 = (ScrollView)findViewById(R.id.scrollview1);
ScrollView sv2 = (ScrollView)findViewById(R.id.scrollview2);

sv1.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {
  @Override
  public void onScrollChanged() {
    sv2.scrollTo(sv1.getScrollX(), sv1.getScrollY());
  }
});

代码示例来源:origin: gdutxiaoxu/TouchDemo

/**
 * 在界面切换的时候会调用这个方法
 * true 表示可见
 * FALSE 表示不可见
 *
 * @param isVisibleToUser
 */
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
  super.setUserVisibleHint(isVisibleToUser);
  Log.i(TAG, "setUserVisibleHint: mTitle=" + mTitle + "  " + " isVisibleToUser=" +
      isVisibleToUser);
  if (isVisibleToUser) {//表示界面可见
    if (mNoHorizontalScrollView != null) {// 之所以判断是否为空,
      Log.i(TAG, "setUserVisibleHint: mTitle=" + mTitle + "  " + " isVisibleToUser=" +
          isVisibleToUser + "mScrollY=" + mScrollY);
      //                mNoHorizontalScrollView.setDescendantFocusability(ViewGroup
      // .FOCUS_BLOCK_DESCENDANTS);
    }
  } else {// 表示界面不可见
    if (mNoHorizontalScrollView != null) {
      mScrollX = mNoHorizontalScrollView.getScrollX();
      mScrollY = mNoHorizontalScrollView.getScrollY();
      Log.i(TAG, "setUserVisibleHint: mTitle=" + mTitle + "  " + " isVisibleToUser=" +
          isVisibleToUser + "mScrollY=" + mScrollY);
    }
  }
}

代码示例来源:origin: adafruit/Bluefruit_LE_Connect_Android

public void scrollToGroup(int groupPosition, View view, ScrollView parentScrollView){
    final float baseY = getY();
    final float currentGroupPosY = baseY + view.getY();
    final int currentScrollY = parentScrollView.getScrollY();
    final View nextGroupView = findViewWithTag(groupPosition+1);

    if (currentScrollY > currentGroupPosY) {
      parentScrollView.smoothScrollTo(parentScrollView.getScrollX(),  view.getTop());
    }
    else if (nextGroupView != null) {
      final float nextGroupPosY = baseY + nextGroupView.getY();
      if (currentScrollY + parentScrollView.getHeight() < nextGroupPosY) {
        parentScrollView.smoothScrollTo(0,  nextGroupView.getBottom());
      }
    }
    else {
      parentScrollView.smoothScrollTo(parentScrollView.getScrollX(), getBottom()-parentScrollView.getHeight());
    }
  }
}

代码示例来源:origin: wallabag/android-app

scrollView.smoothScrollTo(scrollView.getScrollX(), newYOffset);
} else {
  scrollView.scrollTo(scrollView.getScrollX(), newYOffset);

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

sketchData.append(sketchFile.getFragment().getCodeEditText().getSelectionEnd());
sketchData.append(',');
sketchData.append(sketchFile.getFragment().getCodeScroller().getScrollX());
sketchData.append(',');
sketchData.append(sketchFile.getFragment().getCodeScroller().getScrollY());

代码示例来源:origin: vihuela/RAD

mNestedScrollView.scrollTo(mNestedScrollView.getScrollX(), 0);

相关文章

ScrollView类方法