I try to move image in android.
I prepare the image.
int resid = context.getResources().getIdentifier("s066", "drawable", context.getPackageName()); mImage = context.getResources().getDrawable(resid); mImage.setBounds(0, 0, mImage.getIntrinsicWidth(), mImage.getIntrinsicHeight() );I prepare GestureDetector for getting onScroll event.
mGestureDetector = new GestureDetector(context, this);I get touch event.
mGestureDetector.onTouchEvent(ev);onScroll get moving position and call invalidate() for onDrow.
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { Log.d("book", "distanceX=" + distanceX + " distanceY=" + distanceY); mTranslateX -= distanceX; mTranslateY -=distanceY; invalidate(); return false; }onDrow.
@Override public void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.save(); canvas.translate(mTranslateX, mTranslateY); mImage.draw(canvas); canvas.restore(); }source code is here. Please suggest your android issue by twitter or mail, I would try to clear up your issue.
0 件のコメント:
コメントを投稿