I tried removing canvas.restore(), but its the same behaviour. Must be
something else is wrong.

i added an another statement for testing purpose canvas.drawLine, and
it is working as expected, but not drawText. I don't know the reason
why the first time it is working and from second time on, its not
working. If there is any issue with textSize or layout or anything, it
shouldn't even work on the first time.

Its the same case even if you extend a View and try to drawText in the
overridden onDraw method. The first you render the view, the drawText
method will render the text, if you create an another instance of that
view and try to render the text, it will not be visible. It is
happening only with drawText and not with methods like drawLine and
others.



On Jul 3, 7:17 am, MrChaz <[email protected]> wrote:
> you're calling canvas.restore() which clears out all changes since the
> last call of canvas.save()
> I'd try taking out that line.
>
> On Jul 2, 8:57 pm, Casper <[email protected]> wrote:
>
> > public class TCheckBox extends CheckBox{
> > public void onDraw(Canvas canvas){
>
> >                Paint tTextPaint = new Paint();
> >                 tTextPaint.setColor(Color.BLACK);
>
> >                 canvas.drawText("mtext1", getPaddingLeft(), getBottom(),
> > tTextPaint);
>
> >                 int width = getWidth();
>
> >                 Paint tTextPaint2 = new Paint();
> >                 tTextPaint2.setColor(Color.BLACK);
> >                 int tSize = (int)tTextPaint2.measureText("$0000.00");
> >                 canvas.drawText("mtext2", width - tSize, getBottom(), 
> > tTextPaint2);
> >                 canvas.restore();
> >  }
>
> > }
>
> > public void renderCheckBox(){
> >  mTCheckBox[mCheckBoxCounter] = new TCheckBox(this);
>
> >                            if(mTCheckBox[mCheckBoxCounter] != null){
>
> >                                
> > linearLayout.addView(mTCheckBox[mCheckBoxCounter]);
> >                                mCheckBoxCounter++;
> >                            }
> >                            sView.postInvalidate();
> >                    }
> >   }
>
> > My first call to renderCheckBox could render the check box with text1,
> > and text2. From second time onwards, my text is not being rendered but
> > the checkBox is getting rendered. I am not knowing what might be the
> > reason for the failure. Could some one help with this problem.
--~--~---------~--~----~------------~-------~--~----~
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