Looking at your code, you're drawing the bitmap at the top-left of the
canvas (i.e. canvas.drawBitmap(bitmap, 0, 0 ...).  Presumably, you're
precalculating where the bitmap needs to be drawn (it's top-left
coordinate) and using those values in the drawBitmap() call?

The onDraw method will only draw what you tell it to.  So, what I
presume is happening is that you're asking it to first render this:

1 0 0
0 0 0
0 0 0

which it does, then you ask it to render the bitmap at (I'm assuming
that each '1' is a single bitmap):

0 0 0
0 1 0
0 0 0

The problem is, is that you've not told it about the first bitmap (at
the top-left corner), so it doesn't bother drawing that and just
renders the bitmap in the middle.

Thus, to fix this, you need to be able to keep a track of all the
bitmaps that you want to draw, and where they're to be drawn.

On Mar 4, 8:09 am, CMF <[email protected]> wrote:
> Let consider this is my tile view (which is a bitmap):
>
> 0 0 0
> 0 0 0
> 0 0 0
>
> First, I have change the view to
>
> 1 0 0
> 0 0 0
> 0 0 0
>
> Second, I would like to change the middle one, and I expect the result
> is
> 1 0 0
> 0 1 0
> 0 0 0
>
> However, the view give the result:
> 0 0 0
> 0 1 0
> 0 0 0
>
> Is there any method that I can draw the particular part but now the
> whole view?
> Here is my onDraw()
>
> @Override
>         protected void onDraw(Canvas canvas)
>         {
>                 super.onDraw(canvas);
>                 Bitmap bitmap = getImage(R.drawable.tileboard);
>                 bitmap.setDensity(canvas.getDensity());
>                 canvas.drawBitmap(bitmap, 0, 0, new 
> Paint());//drawtilebackground
>         }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to