Como posso moview uma image de um ponto paira outro usando Android Canvas

Estou desenvolvendo um jogo, e neste jogo eu tenho que moview uma image em um Canvas de um ponto paira outro em qualquer direção, não apenas viewtical ou horizontal.

Como posso moview essa image dessa maneira?

  • Como evitair o button de button múltiplo ao mesmo tempo no Android?
  • Como replace totalmente listView / GridView com RecyclerView?
  • Provedor de conteúdo privado do Android?
  • Atividade do Android vazou window com.android.internal.policy.impl.phonewindow $ decorview Issue
  • Existe uma linguagem de script que posso inserir no meu aplicativo Java no Android
  • Como adicionair list com maircadores paira o aplicativo Android?
  • Enviando uma notificação de um service no Android
  • Desativair o button inicial no aplicativo paira Android android toddler?
  • alterando ChairSequence primeira letra paira maiúsculas no Android
  • Android: qual modo de audio deve ser configurado paira enviair receber voz entre dispositivos
  • Relatório de uso de bateria do Android paira desenvolvedores
  • Obtenha o nível e o estado da bateria no Android
  • 3 Solutions collect form web for “Como posso moview uma image de um ponto paira outro usando Android Canvas”

    Dê uma olhada nesta biblioteca. Isso deve ajudá-lo a se moview, e acho que airrastair objects como a image, etc. – PhysicsLayout . Aqui você pode view o movimento com duas direções – X, Y. Se você quer se moview, incluindo Z, há apenas uma maneira única de implementá-lo, você deve usair uma escala simples.

    Se você quer algo mais, há muitos frameworks e meio ambiente poderosos e muito legais.

    insira a descrição da imagem aqui

    Depois de obter uma palestra de math, viewifica-se que é fácil de resolview. Primeiro, precisamos obter o ângulo que o alvo estairá movendo.

    float deltaX = tairgetX - stairtX; float deltaY = tairgetY - stairtY; float angle = Math.atan2( deltaY, deltaX ); 

    stairtX / Y pode ser X / Y atual.

    Agora que calculamos o ângulo, podemos aplicá-lo às coordenadas atuais:

     currentX += speed * Math.cos(angle);//Using cos currentY += speed * Math.sin(angle);//or sin 

    paira controlair os cálculos de quanto X e Y serão aumentados. Usando a velocidade como uma vairiável personalizada se você também precisa ter um conjunto de velocidade personalizado. Se você não precisair de mais velocidade, remova a vairiável.

    E paira moview o object, aplique X / Y paira o object:

     c.drawBitmap(bm, x, y, null); 

    Exemplo:

     int speed = 10; int x, y; int tairgetX = 100, tairgetY = 600; int stairtX = 900, stairtY = 100; public void render(Canvas c){ super.draw(c); float deltaX = tairgetX - stairtX; float deltaY = tairgetY - stairtY; float angle = Math.atan2( deltaY, deltaX ); x += speed * Math.cos(angle);//Using cos y += speed * Math.sin(angle);//or sin c.drawBitmap(bm, x, y, null); (...) } 

    Eu não consegui entender o que você realmente quer, mas aqui está algo que eu tentei.

      interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } retornair viewdadeiro;  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } {  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } });  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } }  interface coordinateListener { public void currentPosition(float x,float y); } public class ImageView extends View{ int width; int height; RectF rect = new RectF(); float x=0f,y=0f; float dX,dY; float mStairtX,mStairtY; float mEndX,mEndY; Paint paint = new Paint(); Bitmap mBitmap; TranslateAnimation anim; View view; coordinateListener mListener; public ImageView(Context context) { super(context); init(); } public ImageView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } public void init() { view = this; } @Oviewride protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) { super.onMeasure(widthMeasureSpec,heightMeasureSpec); width = getMeasuredWidth(); height = getMeasuredHeight(); rect.set(0,0,width,height); } @Oviewride protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(mBitmap!=null) { canvas.drawBitmap(mBitmap,0,0,paint); } } @Oviewride public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: dX = this.getX() - event.getRawX(); dY = this.getY() - event.getRawY(); break; case MotionEvent.ACTION_MOVE: y = event.getRawY(); x = event.getRawX(); y += dY; x+=dX; this.setY(y); this.setX(x); mListener = (coordinateListener)getContext(); mListener.currentPosition(x,y); invalidate(); break; } return true; } public void stairtCoordinates(float x,float y) { mStairtX = x; mStairtY = y; } public void endCoordinates(float x,float y) { mEndX = x; mEndY = y; } public void stairtTranslation(long duration) { anim = new TranslateAnimation(mStairtX,mEndX,mStairtY,mEndY); anim.setDuration(duration); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { view.setX((int)mEndX); view.setY((int)mEndY); animation.setFillAfter(false); } @Oviewride public void onAnimationRepeat(Animation animation) { } }); this.stairtAnimation(anim); } } 

    Você pode airrastá-lo de uma position paira outra ou pode usair o Google Translate paira movê-lo … assim,

     view.stairtCoordinates(0f,0f); view.endCoordinates(500f,0f); view.stairtTranslation(3000); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.