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. Using Handler

Hi,

In my main activity (ListActivity) i start a thread in background to
do some work and always in the activity i use a Handler to receive a
message, containing in the filed obj one vector with many objects,
from the thread when it finishes its work. Obviously i have overridden
the methods handleMessage(Message m).
It seems to work fine if I don't rotate the screen.

I would like to know what happen to the handler if i rotate the screen
(like in the G1 using keybord). I know the the activity is destroyed
with onDestroy and created again with onCreate(). and my handler? what
happen to my handler?

-- 

2. All U.S. Android phones to receive Android 2.1, but some will require a wip

wah masih ada teman penyihir nih,hehe ga sabar lihat magic jadi enwan tanpa
ada yg broke

Jonitan17 , HTC MAGIC




Asik nih....

http://androidandme.com/2010/02/news/all-u-s-android-phones-to-receive-android-2-1-but-some-will-require-a-wipe/

-- 
"Indonesian Android Community [id-android]"

3. salam kenal dari murid baru

4. All U.S. Android phones to receive Android 2.1, but some will require a wip

5. Stuck Pada tulisan "PLANET MAX" Sesudah Mem PARTISI HTC MAGIC, ROM ECLAIR 2.1 [MADE BY ME/ From XDA Developer] ada solusi?

6. Widget does not render on wvga854 ?

7. Special Thanks to Suhu SA dan LA