标签: touch-event

使用jQuery touchwipe默认擦除一些擦除

我正在使用这个精彩的插件来捕获移动设备上的擦除事件:http://www.netcu.de/jquery-touchwipe-iphone-ipad-library

我正在使用该页面源代码中的代码来使我的图像库循环应用.但是,我的图库是屏幕的整个宽度.不幸的是,touchwipe似乎阻止了默认的上下擦除在页面上下滚动.有没有办法让它使用默认行为,除非指定了其他行为?

$(document).ready(function() {
    $('#imagegallery').cycle({
        timeout: 0,
        fx: 'scrollHorz',
        next: '#next',
        prev: '#prev' 
    });

    $("#imagegallery").touchwipe({
        wipeLeft: function() {
            $("#imagegallery").cycle("next");
        },
        wipeRight: function() {
            $("#imagegallery").cycle("prev");
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

我也对实现同样效果的其他替代方案持开放态度(其他插件,其他方法).谢谢!

iphone jquery android touch touch-event

5
推荐指数
2
解决办法
5343
查看次数

android绘图触摸事件

我正在尝试制作一个应用程序,使用户可以触摸屏幕并根据用户的手指坐标绘制图像.这是我的代码:

public class DrawingBoard extends View {

        Drawable editIcon = getResources().getDrawable(R.drawable.icon);
        Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.background);

        float xPos = 0;
        float yPos = 0; 

        public DrawingBoard (Context context) {
            // TODO Auto-generated constructor stub
            super (context);            
        }
        @Override
        protected void onDraw (Canvas canvas) {
            super.onDraw(canvas);

            canvas.save();
            canvas.drawBitmap(mBitmap, 0, 0, null);
            canvas.translate(xPos, yPos);
            editIcon.draw(canvas);
            canvas.restore();

            invalidate();
        }
        @Override
        public boolean onTouchEvent (MotionEvent event) {

            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN : 
                    xPos = event.getX();
                    yPos = event.getY();
                    break;
            }

            return true;

        } …
Run Code Online (Sandbox Code Playgroud)

android canvas bitmap touch-event

5
推荐指数
1
解决办法
2万
查看次数

Android ACTION_UP甚至从未调用过

我正在尝试制作一个小型的机器人Jump and Run游戏,但我的问题是我无法正确配置事件ACTION_UP.在这里我的代码:

public boolean onTouchEvent(MotionEvent event) {
    switch(event.getAction()){
    case MotionEvent.ACTION_DOWN:
        Log.d("OTE", "down"); 
        touchDownTrue = true;
        break;
    case MotionEvent.ACTION_UP:
        Log.d("OTE", "UP"); 
        touchDownTrue = false;
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)

从未调用MotionEvent.ACTION_UP的情况,我不知道为什么,如果我使用ACTION_CANCEL也会发生同样的情况

android touch-event

5
推荐指数
1
解决办法
7762
查看次数

Android MotionEvent ACTION_MOVE效率.如何提高性能?

我目前正在开发一个允许自由绘图的应用程序.

我目前使用的方法如下:

currentLine是一个列表,用于保存ACTION_MOVE返回的所有点的历史记录.

public boolean onTouchEvent (MotionEvent event) {

        switch (event.getAction()) {
            case MotionEvent.ACTION_MOVE:
                Point p = new Point(event.getX(),event.getY());
                currentLine.addPoint(p);
                    invalidate();
                break;
        }

        return true;

}
Run Code Online (Sandbox Code Playgroud)

然后我把这些观点onDraw用我班上的方法画出来.

@Override
protected void onDraw(Canvas c) {
    super.onDraw(c);

    //Draw Background Color
    c.drawColor(Color.BLUE);

    //Setup Paint
    Paint p = new Paint();
    p.setStyle(Style.FILL);
    p.setColor(COLOR.WHITE);

    //iterate through points
    if(currentLine.size()>0){
        for(int x = 0;x<currentLine.size();x++){
            c.drawCircle(currentLine.get(x).getX(), currentLine.get(x).getY(), 3, p);
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

这种方法效果很好,没有任何延迟或任何问题.

除此之外,它没有得到它需要的足够的分数.

例如,如果我要在整个屏幕上快速拖动我的手指,它可能只会绘制整个事件的15个点.

如何提高MotionEvent的性能/速度?我怎样才能获得更多积分?或者我还应该做些什么呢?

- - 编辑 - -

我自己设法解决了这个问题. …

performance android touch-event

5
推荐指数
2
解决办法
6304
查看次数

Android GestureDetector无法使用FrameLayout检测onScroll事件

我有一个扩展FrameLayout的视图,并且需要通知其滚动事件。此视图具有实现GestureDetector的类的实例,该类由重写的onInterceptTouchEvent方法调用。

    private class HorizontalScrollListener implements OnGestureListener {
    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        ...
        return false;
    }
    @Override
    public boolean onDown(MotionEvent e) { 
         ...
         return false; 
    }
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { 
        return false;
    }
    @Override
    public void onLongPress(MotionEvent e) {
        ...
        System.out.println();
    }
    @Override
    public void onShowPress(MotionEvent e) {}
    @Override
    public boolean onSingleTapUp(MotionEvent e) { return false; }
}
Run Code Online (Sandbox Code Playgroud)

唯一的问题是,当我尝试滚动时,onDown和onLongPress方法可能会被调用,但实际的onScroll方法却从未被调用。

    @Override
public boolean onInterceptTouchEvent(MotionEvent event) { …
Run Code Online (Sandbox Code Playgroud)

android scroll android-custom-view touch-event android-framelayout

5
推荐指数
1
解决办法
2192
查看次数

如何在谷歌地图中绑定标记的触摸事件?

谷歌地图api不支持触摸事件

但现在我需要在地图和标记上做一些事情,比如长按地图,点击标记,拖动标记.

我想做的就像iOS的谷歌地图客户端一样

javascript html5 google-maps google-maps-api-3 touch-event

5
推荐指数
2
解决办法
1万
查看次数

Android:子视图从Jelly Bean中的父视图共享压缩状态

代码注释:1.RelativeLayout Clickable attr设置为true,其中有一个子视图,其Clickable attr设置为false.2.没有任何duplicateParentState attr,换句话说,duplicateParentState为false.3.子视图是TextView,其textColor是颜色选择器,因此它可以检查按下的状态.

行为:在level16之前,当单击RelativeLayout时,按下的状态不会传输到他的chlid视图.但是在16级或更高级别,它可以.

原因:setPressed ------> dispatchSetPressed ------>将压缩状态传递给子视图-----> childView.setPressed

15级的View.java onTouchEvent,

case MotionEvent.ACTION_DOWN:
                mHasPerformedLongPress = false;

                if (performButtonActionOnTouchDown(event)) {
                    break;
                }

                // Walk up the hierarchy to determine if we're inside a scrolling container.
                boolean isInScrollingContainer = isInScrollingContainer();

                // For views inside a scrolling container, delay the pressed feedback for
                // a short period in case this is a scroll.
                if (isInScrollingContainer) {
                    mPrivateFlags |= PREPRESSED;
                    if (mPendingCheckForTap == null) {
                        mPendingCheckForTap = new CheckForTap();
                    }
                    postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout()); …
Run Code Online (Sandbox Code Playgroud)

android view touch-event

5
推荐指数
0
解决办法
1641
查看次数

如何用手指画出多条线?(机器人)

我试图画出这样的多行:

`

l1 = new Path();

l2 = new Path();
l3 = new Path();
l4 = new Path();`
---
`mPathList.add(l1...l4);`
---

    `public void onDraw(Canvas canvas) {
    ...

for (Path path : mPathList) {
canvas.drawPath(path, mOverlayPaint);

    }
    ...
    }`

    ---
    `case MotionEvent.ACTION_MOVE:
    int X = (int)me.getRawX();
    int Y = (int)me.getRawY();

    l1.moveTo(X, Y);
    l2.moveTo(X + 5, Y);
    l3.moveTo(X + 10, Y);
    l4.moveTo(X + 15, Y);
    break;`
Run Code Online (Sandbox Code Playgroud)

但是当我想要画一些东西时,FPS会慢慢减少.任何想法如何让它工作正常?PS对不起我的英文,拜托

performance android canvas touch-event

5
推荐指数
1
解决办法
1948
查看次数

Onfling和OnTouch无法一起使用

我有一个可扩展的列表视图.我正在每个项目的向左滑动上实现listItem的删除.

我使用自定义适配器来填充listview项目.

public class InsightsListAdapter extends BaseExpandableListAdapter {
@Override
public View getGroupView(final int groupPosition, boolean isExpanded,
        View convertView, ViewGroup parent) {
    View row = convertView;
    row = inflater_.inflate(R.layout.insight_list_item, null);

    final GestureDetector gdt = new GestureDetector(new GestureListener());
    row.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            swipedViewPosition_=groupPosition;
            swipedView_=v;
            gdt.onTouchEvent(event);
            return true;
        }
    });

    return row;
}
Run Code Online (Sandbox Code Playgroud)

我正在使用GestureListener,如下所示

private static final int SWIPE_MIN_DISTANCE = 200;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;

private class GestureListener extends SimpleOnGestureListener {

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

android expandablelistview touch-event android-listview onfling

5
推荐指数
1
解决办法
610
查看次数

Android:垂直Recyclerview内的Horizo​​ntal Recyclerview

这似乎是android中相当普遍的模式.我正在尝试创建类似Facebook显示广告的方式:

Facebook广告

您可以看到它们具有外部垂直回收视图,内部水平回收视图作为外部垂直recyclerview适配器中的项目之一.

我按照Google的指南"在ViewGroup中管理触摸事件" - http://developer.android.com/training/gestures/viewgroup.html,因为Recyclerview扩展了ViewGroup,其代码类似于我想要做的.

我对它进行了一些定制,以便检测Y轴的移动而不是X轴的移动,并将其应用到外部垂直再循环视图.

/**
 * Created by Simon on 10/11/2015.
 *///This is the recyclerview that would allow all vertical scrolls
public class VerticallyScrollRecyclerView extends RecyclerView {


    public VerticallyScrollRecyclerView(Context context) {
        super(context);
    }

    public VerticallyScrollRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public VerticallyScrollRecyclerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }


    ViewConfiguration vc = ViewConfiguration.get(this.getContext());
    private int mTouchSlop = vc.getScaledTouchSlop();
    private boolean mIsScrolling;
    private float startY;

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        final int …
Run Code Online (Sandbox Code Playgroud)

android touch-event android-layout motionevent android-recyclerview

5
推荐指数
1
解决办法
2777
查看次数