Monday, August 1, 2011

[android-developers] Re: Drawing Circles in a Row

Thanks, Kostya! I followed your suggestions but I can only see one
circle. I'm adding these circles to a LinearLayout in a View in which
all the elements are added programmatically. This View is a child of a
ViewFlipper. Every time the View flips to the next one, the circles
disappear. Any suggestions on how to solve these problems?

Thanks,
Y

On Aug 1, 2:28 pm, Kostya Vasilyev <kmans...@gmail.com> wrote:
> Call super.onDraw() first thing in your method, just once.
>
> And don't call invalidate(), as that would cause another redraw, and
> another, and another..... at some point the value of "k" will increase
> to place the circles beyond the right edge of the screen (you will want
> to reset "k" somewhere, possibly right here inside onDraw).
>
> -- Kostya
>
> 01.08.2011 22:20, Y пишет:
>
> >    protected void onDraw(Canvas canvas) {
>
> >            for (int i = 0; i<  numOfCircles; i++) {
> >                    super.onDraw(canvas);
> >                    k = k + 10;
> >                    canvas.drawCircle(x + k, y, r, gPaint);
> >                    invalidate();
> >            }
> >       }
>
> --
> Kostya Vasilyev

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

No comments:

Post a Comment