As in many other graphics rendering system, your code is the handler of some event invoked when the drawing is required. You hard-coded the bitmap coordinates, so what would you expect. You have to make these coordinate depending on some field(s) of declaring class, say,
bitmapX
,
bitmapY
. You modify the values of these fields and then redraw the view.
How? If I can assume that your code is declared in the class derived from the class
SurfaceView
, you can call one of the
invalidate
methods:
http://developer.android.com/reference/android/view/SurfaceView.html[
^].
It will eventually invoke the event (pun not intentional) cause re-rendering. Depending on invalidation method, it will redraw "dirty" area (rectangle, object, etc.). In your case, it should redraw at least the area calculated as the union of the "old" and "new" areas occupied by the bitmap.
—SA