1

What i would like to do is draw a rectangle and put some dynamic text inside,this is possible?

I guess isnt,but there are any way to resolve this??

Anyway im drawing the rectangle using this example here..
rectangle -example

Community
  • 1
  • 1
user1866731
  • 481
  • 2
  • 5
  • 13
  • 1
    You will have to be a lot more precise on what you want to achieve. For example, why isn't a TextView with a border good enough? – Simon Dec 16 '12 at 12:46
  • I didnt know that a border was possible in android :O Well,maybe that is my solution.. – user1866731 Dec 16 '12 at 12:49

1 Answers1

0

The example you are giving is rather static. You could also go for a more dynamic approach where you override the onDraw method of a View:

public class MyView extends View {
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint p = new Paint();
        p.setColor(Color.BLACK);
        canvas.drawRect(10, 10, 10, 10, p);
        p.setColor(Color.WHITE);
        canvas.drawText("Ohai!", 0, 5, 20, 20, p);
    }
}

You just then put this View on your panel where you want it. There are of course even more methods to use for this, just have a look at the Canvas class

Or you could of course just some kind of TextView you can customize (add some borders etc).

ndsmyter
  • 6,535
  • 3
  • 22
  • 37