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


Java TouchUtils.drag方法代码示例

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


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

示例1: swipeHorizontally

import android.test.TouchUtils; //导入方法依赖的package包/类
public static void swipeHorizontally(InstrumentationTestCase test, View v, Direction direction) {
    int[] xy = new int[2];
    v.getLocationOnScreen(xy);

    final int viewWidth = v.getWidth();
    final int viewHeight = v.getHeight();

    float distanceFromEdge = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            v.getResources().getDisplayMetrics());
    float xStart = xy[0] + ((direction == Direction.LEFT) ? (viewWidth - distanceFromEdge) : distanceFromEdge);
    float xEnd = xy[0] + ((direction == Direction.LEFT) ? distanceFromEdge : (viewWidth - distanceFromEdge));
    float y = xy[1] + (viewHeight / 2.0f);

    TouchUtils.drag(test, xStart, xEnd, y, y, DRAG_STEP_COUNT);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:16,代码来源:UiTestUtils.java

示例2: swipeVertically

import android.test.TouchUtils; //导入方法依赖的package包/类
public static void swipeVertically(InstrumentationTestCase test, View v, Direction direction) {
    int[] xy = new int[2];
    v.getLocationOnScreen(xy);

    final int viewWidth = v.getWidth();
    final int viewHeight = v.getHeight();

    float distanceFromEdge = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            v.getResources().getDisplayMetrics());
    float x = xy[0] + (viewWidth / 2.0f);
    float yStart = xy[1] + ((direction == Direction.UP) ? (viewHeight - distanceFromEdge) : distanceFromEdge);
    float yEnd = xy[1] + ((direction == Direction.UP) ? distanceFromEdge : (viewHeight - distanceFromEdge));

    TouchUtils.drag(test, x, x, yStart, yEnd, DRAG_STEP_COUNT);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:16,代码来源:UiTestUtils.java

示例3: swipeToRight

import android.test.TouchUtils; //导入方法依赖的package包/类
public void swipeToRight(ActivityInstrumentationTestCase2 aitc2){
    DisplayMetrics dm = new DisplayMetrics();
    testActivity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    int height = dm.heightPixels;

    TouchUtils.drag(aitc2, width - 30, 30, height / 2, height / 2, 5);
}
 
开发者ID:TeamWhat,项目名称:what-stored-in-a-mobile-device-android,代码行数:9,代码来源:MockUserActions.java

示例4: dragViewToX

import android.test.TouchUtils; //导入方法依赖的package包/类
public static int dragViewToX(InstrumentationTestCase test, View v, int gravity, int toX) {

    if (gravity != Gravity.CENTER) {
      throw new IllegalArgumentException("Can only handle Gravity.CENTER.");
    }
    Point point = getCenterOfViewOnScreen(test, v);

    final int fromX = point.x;
    final int fromY = point.y;

    int deltaX = Math.abs(fromX - toX);

    TouchUtils.drag(test, fromX, toX, fromY, fromY, deltaX);

    return deltaX;
  }
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:17,代码来源:TestUtilities.java


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