print onto a custom drawView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

print onto a custom drawView

Postby isaackearl » Mon Jan 26, 2009 8:41 am

ya I have a custom view that basically just animates some imgs bouncing around the screen. I would really like to figure out how to print some text onto the view. I can't figure out how to do this. can i layer views somehow? like make a regular txtview and layer the drawview over it and somehow still see the txtview?

thanks in advance.
isaackearl
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Nov 25, 2008 8:09 pm

Top

Postby MrSnowflake » Mon Jan 26, 2009 12:31 pm

Implement your own View and in the onDraw() you paint the image and then you paint the text you want.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby isaackearl » Mon Jan 26, 2009 4:33 pm

thanks mr snowflake, this makes sense but I haven't been able to figure it out quite yet.. here is the code i'm trying to use

for (int i = 0; i < ballCount; i++) {
theCanvas.drawBitmap(ballList.get(i).getBitmap(), ballList.get(i)
.getX(), ballList.get(i).getY(), null);
theCanvas.drawText("please work", 0, 0, null);
}

this is a method i have that is called right after invalidate in the onDraw method. the program force closes on opening. if I try and specify the paint color and all that stuff instead of putting null it seems to crash too, or maybe I'm doing it wrong. If I delete theCanvas.drawText line then it works and the balls will bounce around, but trying to do a drawText just makes it crash...
isaackearl
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Nov 25, 2008 8:09 pm

Postby isaackearl » Mon Jan 26, 2009 4:43 pm

woo, nevermind got it working! just was crashing because of the way that I declared paint object.. I found a great tutorial for this kinda stuff here:

http://bestsiteinthemultiverse.com/2008 ... s-example/
isaackearl
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Nov 25, 2008 8:09 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests