Hi thanks for the reply.
i even tried that. Interesting part is, except cavas.drawText for drawing text any other paint call is working. if you try by your self, you will see the same thing happening. i added a statement for canvas.drawLine(); this is working on every call. But canvas.drawText is able to render my text only once. i verified the textpaint value. i verified the bottom, top and i even hardcoded everything and found the same thing happening. its kind of weird. the api call only mentions that, as per the chosen alignment, the text will drawn with respect to the x, y origin. I struggled with this problem till night 3, couldn't find the solution. i even tried extending the view and calling drawText in the overridden OnDraw method, is doing the same thing. Stephen suggested trying setTextSize, even that didnt work. The point is, first instance of my extended CheckBox is able to draw the text, the second time, i create an instance and its the same onDraw method that gets called, and the text is not visible, but the checkBox is visible if i have super.onDraw in that method. 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 -~----------~----~----~----~------~----~------~--~---

