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. Unable to recover key : Message when exporting android project using Eclipse for release

I am tried to export my project using eclipse. I have a keystore that
I created using keytool and I know the key's alias and password. But
when I try to use this keystore/key, I get the message 'Cannot recover
key'. Even when trying to do it manually using jarsigner utility, I
run into same issues. Could anybody provide me pointers to fix this
issue as I am getting crazy trying to find solution for this.

-- 

2. Media Controller in VideoView should never disappear

Guys at present the MediaController for video view is visible only for
3 seconds.
I want the controller to be there permanently till the song finishes
i know there is something like mc.show(0)
but i dont know how and where to use this code

-- 

3. Receiving Exception 'java.lang.RuntimeException: setParameters failed' while using NyARToolkit in Android 2.1

4. Media metadata update

5. Android to bluecove

6. How do I get pen type events in my app?

7. Fwd: Problem in Handler