Dynamically displaying text anywhere on the screen

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

Dynamically displaying text anywhere on the screen

Postby SorkarGG » Wed Jan 27, 2010 1:57 am

Hi, I'm actually re-discovering android after quite some time.

I would like to be able to display text anywhere I'd like on the screen when I touch it. Oh and it should be on top of a drawable (which is in this case a RectShape but whatever).

The main goal would be to be able to select one of those object after it's creation to do stuff with it (which is another story).

For the moment I'm able to display the Rects on the screen, but I can't find a way to display text without having to rely on Layouts. Unfortunately I didn't find a way to put a TextView at (x,y) where it would be the coordinates of the MotionEvent.

Is there a way to put text as a drawable? Or any alternative?

this seems to be pretty basic so I'm sure there is a solution

Image
as I said
SorkarGG
Freshman
Freshman
 
Posts: 5
Joined: Sun Feb 01, 2009 3:56 pm

Top

Postby SorkarGG » Wed Jan 27, 2010 3:51 am

nevermind I found out...

sry for double post


Code: Select all
protected void onDraw(Canvas canvas) {
        mDrawable.draw(canvas);
        //this
        canvas.drawText(text, 0, text.length(), x, y, mDrawable.getPaint());
    }
as I said
SorkarGG
Freshman
Freshman
 
Posts: 5
Joined: Sun Feb 01, 2009 3:56 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests