"One of the Android game development": Set up full screen and simple graphic drawing

Source: Internet
Author: User
Tags set background

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.