当前位置: 首页>>代码示例>>Java>>正文


Java HorizontalScrollView.getScrollX方法代码示例

本文整理汇总了Java中android.widget.HorizontalScrollView.getScrollX方法的典型用法代码示例。如果您正苦于以下问题:Java HorizontalScrollView.getScrollX方法的具体用法?Java HorizontalScrollView.getScrollX怎么用?Java HorizontalScrollView.getScrollX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.HorizontalScrollView的用法示例。


在下文中一共展示了HorizontalScrollView.getScrollX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testScrollToCommand

import android.widget.HorizontalScrollView; //导入方法依赖的package包/类
/**
 * Verify that 'scrollTo' command makes ScrollView start scrolling
 */
public void testScrollToCommand() throws Exception {
  HorizontalScrollView scrollView = getViewAtPath(0);
  ScrollViewTestModule jsModule =
      getReactContext().getCatalystInstance().getJSModule(ScrollViewTestModule.class);

  assertEquals(0, scrollView.getScrollX());

  jsModule.scrollTo(300, 0);
  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.getScrollX() > 0) {
      break;
    }
    Thread.sleep(interval);
  }
  assertNotSame(0, scrollView.getScrollX());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:28,代码来源:ReactHorizontalScrollViewTestCase.java

示例2: hscrollOnDrag

import android.widget.HorizontalScrollView; //导入方法依赖的package包/类
private void hscrollOnDrag(View view, DragEvent event, HorizontalScrollView scrollView) {
    float tx = view.getLeft() + event.getX();

    if (isAncestor(scrollView, view)) {

        int thresh = scrollView.getWidth() / 6;

        if (tx < scrollView.getScrollX() + thresh) {
            scrollView.smoothScrollBy(-10, 0);
        } else if (tx > scrollView.getScrollX() + scrollView.getWidth() - thresh) {
            scrollView.smoothScrollBy(10,0);
        }
    }
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:15,代码来源:MainActivity.java

示例3: testScrollAndClick

import android.widget.HorizontalScrollView; //导入方法依赖的package包/类
@Test
public void testScrollAndClick() throws Throwable {
  final Activity activity = activityTestRule.getActivity();
  final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();

  final Button button = activity.findViewById(R.id.button);
  final View.OnClickListener mockClickListener = mock(View.OnClickListener.class);
  button.setOnClickListener(mockClickListener);

  // Emulate a click on the button to verify that the registered listener is invoked
  // prior to performing a horizontal swipe across the app ba

  final int[] buttonXY = new int[2];
  button.getLocationOnScreen(buttonXY);
  final int buttonWidth = button.getWidth();
  final int buttonHeight = button.getHeight();
  final float emulatedTapX = buttonXY[0] + buttonWidth / 2.0f;
  final float emulatedTapY = buttonXY[1] + buttonHeight / 2.0f;

  emulateButtonClick(instrumentation, emulatedTapX, emulatedTapY);
  verify(mockClickListener).onClick(button);
  reset(mockClickListener);

  final HorizontalScrollView hsv = activity.findViewById(R.id.hsv);
  final int scrollXBefore = hsv.getScrollX();
  // Now scroll / swipe horizontally across our scrollable content in the app bar
  onView(withId(R.id.app_bar)).perform(swipeLeft());
  assertTrue("Horizontal scroll performed", hsv.getScrollX() > scrollXBefore);

  // And emulate another click on the button to verify that the registered listener is still
  // invoked immediately after performing the horizontal swipe across the app bar
  emulateButtonClick(instrumentation, emulatedTapX, emulatedTapY);
  verify(mockClickListener).onClick(button);
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:35,代码来源:AppBarHorizontalScrollingTest.java


注:本文中的android.widget.HorizontalScrollView.getScrollX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。