Example of a simple canvas ?

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Example of a simple canvas ?

Postby Lex » Sun Dec 16, 2007 1:33 am

Hi, my question is probably really dumb but I don't see any example illustrating what I'm looking for.

I have an activity. I call setContentView(R.layout.main), where main.xml is the layout of my main activity.
I'd like to display a red rectangle (using a canvas ) in this main view. How can I do that ?
How to insert a View into another view ?

Thanks,
Lex
Developer
Developer
 
Posts: 30
Joined: Fri Nov 16, 2007 11:03 pm

Top

Postby res » Fri Jan 18, 2008 12:40 am

If you have a View you can use "protected void onDraw(Canvas canvas)" method to paint on the screen.
res
Senior Developer
Senior Developer
 
Posts: 146
Joined: Tue Nov 20, 2007 8:14 pm
Location: United States

Postby plusminus » Fri Jan 18, 2008 1:10 am

Hello Lex,

For cascading Views ( View in View in View...) have a look at the SingleWeatherInfoView of the :src: Android Weather Forecast-Tutorial.
or any main.xml on this board :!: (in most cases everything is surrounded by a LinearLayout...).

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests