Note: This article is rewritten from Li's blog, the original address: http://blog.csdn.net/xiaominghimi/article/details/6089317
First, set the full screen:
Two methods, the first of which are in activity:
Package Com.howlaa.androidgame1;import Android.os.bundle;import Android.view.window;import Android.view.windowmanager;import Android.app.activity;public class Mainactivity extends Activity {@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); This.getwindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); Hide the battery and other information this.requestwindowfeature (window.feature_no_title); Hide the title bar Setcontentview (new MyView (This));}}
The second method is written in the Mainfest.xml file:
Android:theme= "@android: Style/theme.notitlebar" hidden away title bar Android:theme= "@android: Style/theme.notitlebar.fullscreen" Hide the status bar
Two: Draw simple graphics:
Create a new class, Inherit view
Package Com.howlaa.androidgame1;import Android.content.context;import Android.graphics.canvas;import Android.graphics.color;import Android.graphics.paint;import Android.graphics.rect;import Android.graphics.RectF; Import Android.view.view;public class MyView extends View{private Paint paint;public MyView (context context) {Super ( context); Paint = new paint (); Paint.setantialias (TRUE);//Set Brush non-aliased (if not set can see poor effect) This.setkeepscreenon (TRUE);//Set Background solid paint.setcolor (color.red); } @Overrideprotected void OnDraw (canvas canvas) {super.ondraw (canvas); Canvas.drawcolor (color.white);//Set Canvas color rect rect = new Rect (30, 30, 50, 50);//The first two parameters are the coordinates of the upper-left corner, the last two parameters are the lower-right coordinate canvas.drawrect (Rect, paint);//Draw RECTF RECTF = new RECTF (70f,30 F,90F,90F);//RECTF is a rectangular float, with a different precision than rect canvas.drawarc (rectf,0,360,true,paint); Canvas.drawcircle (150, 30, 20, paint);///Note that this points must be a multiple of 4, because 4 is a group, the first two parameters of a set are the start coordinates of the line, the last two parameters are the end coordinates of the line float[] points =new float[]{200f,10f,200f, 40F,300F,30F,400F,70F}; Canvas.drawlines (points, paint); canvas. DrawText ("Hello", +, +, paint);}}
I already know the code in the comments. Look at the effect:
"One of the Android game development": Set up full screen and simple graphic drawing