How to draw some lines in a view element defined in the xml layout

Posted by Nils on Stack Overflow See other posts from Stack Overflow or by Nils
Published on 2010-05-17T03:38:51Z Indexed on 2010/05/17 3:40 UTC
Read the original article Hit count: 321

Filed under:
|
|

Hello,

I have problems drawing some simple lines in a view object (Android programming).

First I created the layout with the view element(kind of painting area) in it (XML file).

[...] < View android:id="@+id/viewmap" android:layout_width="572px" android:layout_height="359px" android:layout_x="26px" android:layout_y="27px" > [...]

... and tried then to access it to draw some lines. Unfortunately the program is running and other UI elements like buttons are displayed, but I can't see the drawings. What's wrong ?

[...] viewmap = (View) findViewById(R.id.viewmap); Canvas canvas = new Canvas(); viewmap.draw(canvas); Paint p = new Paint(); p.setColor(Color.BLUE); p.setStyle(Paint.Style.STROKE); canvas.drawColor(Color.WHITE); p.setColor(Color.BLUE); canvas.drawLine(4, 4, 29, 5, p); p.setColor(Color.RED); viewmap.draw(canvas); [...]

Thanks for help :) !

© Stack Overflow or respective owner

Related posts about android

Related posts about view