Text in of a custom drawable

by Erik H » Wed, 01 Apr 2009 18:11:19 GMT


Sponsored Links
 Hi,

I need help to add text in a custom drawable. I'm looking in tha API
(android.graphics...) but cannot find any way of doing this.

What I basically want is a drawable that contains text that I can
change. Is this even possible today?

It must be a drawable as I use it where a drawable is required.

Thanks!

// Erik
--~--~---------~--~----~------------~-------~--~----~



Text in of a custom drawable

by jefferyfry » Thu, 02 Apr 2009 08:24:03 GMT


 You will need to extend the View you are displaying the drawable and
override the draw method to add your custom text like this:

@Override
        public void draw(Canvas canvas) {
                super.draw(canvas);
                canvas.drawText("Title", x,
                                y, titlePaint);
        }



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Text in of a custom drawable

by Dianne Hackborn » Thu, 02 Apr 2009 09:31:22 GMT


 The drawable's draw() method takes a canvas, so there is no problem having a
drawable use that to draw text.

Also you should almost always implement View.onDraw(), not View.draw().







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~



Text in of a custom drawable

by guruk » Wed, 29 Apr 2009 00:30:39 GMT


 is there a chance to design new drawables dynamicly.

for example right now i have a calendar, each day does have a color
. now i like that its possible that each day does have a drawable
that includes three bars with different colors.

that mean i can create many drawables that fit all possible color
combinations, or i create a new drawable on the fly with the colors i
need

is that possible and how?

chris





--~--~---------~--~----~------------~-------~--~----~



Text in of a custom drawable

by Dianne Hackborn » Wed, 29 Apr 2009 00:56:22 GMT


 Subclass from Drawable, implement your drawing, instantiate it, and give it
to the view you want to have use it.








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. The new Android 1.5 message problem

The problem is when i sent a text it sends it fine, but my phone has
still got that little sending sign next to the text, and this morning
it re-sent all the texts that had a sending icon next to it,


any idea why?

--~--~---------~--~----~------------~-------~--~----~

2. Message counting app

Hello,
i search a app wicht counts all my sms/mms so i can see at the end of
the month how many messages ive sented to wich person this month.

is there any app or method to get that?

Godzkilla

--~--~---------~--~----~------------~-------~--~----~

3. short message controlling

4. How to establish sqlite database in linux?

5. onKeyDown for keyboard keys called in emulator but not on device (G1)

6. Create a bitmap with custom Config

7. bhgfg