I am new to android and trying to write this application which will allow to drag an image. (image is bigger than my phone's screen). The aim is to move this image within the screen. I am able to calculate the distance the image was dragged by counting while ACTION_MOVE, if the movement is very slow. However, if the speed of dragging is increased my count does not match the requirements, I want to determine the speed, but I don't know how. Any other suggestions would be highly appreciated. Here is a part of my code:
- Code: Select all
case MotionEvent.ACTION_MOVE:
movingX=event.getX()-start.x;
speed=??? event.getEventTime();
//speed= 1by default ///very slow, constant dragging
if(speed==1){
counter=1;
}
if(speed==2){
counter=2;
}
if(movingX<0){
count+=counter;
}else{
count-=counter;
}
if(count>0 && count<movable/2){
matrix.set(savedMatrix);
matrix.postTranslate(event.getX() - start.x, 0);
}
if(count>movable/2){
count=(int)movable/2;
}
if(count<0){
count=0;
}
Many thanks in advance for any suggestions!

