Android Development (III): android interface and Game Development

Source: Internet
Author: User

Shows the android interface structure:

 
 

Common interface components:

Textview, listview, and toast.

Interface layout:

LinearLayout: Linear Layout

RelativeLayout: relative Layout

TableLayout: form layout

TabWideget: Switch Tab

AbsoluteLayout: Custom x and y location layout

Game Development

Game Development does not use the above layout method. The game uses a state machine to keep Canvas painting on The view.

You can use Handler or postInvalidate to refresh the view development framework notification interface:

Handler instance:

Handler myHandler = new Handler ()
{
// After receiving the message
Public void handleMessage (Message msg)
{
Switch (msg. what)
{
Case Activity01.REFRESH:
MGameView. invalidate ();
Break;
}
Super. handleMessage (msg );
}
};

Use postInvalidate

Class GameThread implements Runnable
{
Public void run ()
{
While (! Thread. currentThread (). isInterrupted ())
{
Try
{
Thread. sleep (100 );
}
Catch (InterruptedException e)
{
Thread. currentThread (). interrupt ();
}
// Use postInvalidate to directly update the interface in the thread
MGameView. postInvalidate ();
}
}
}

SurfaceView class development framework www.2cto.com

The obvious difference between the SurfaceView class and the view class development framework is that SurfaceView does not need to update the view through threads, but you must use the lockCanvas method to lock the canvas and get the canvas before painting. After painting, you can use the unlockCanvasAndPost method to unlock the canvas and display it on the screen.

Graphics class: paint, canvas, etc.

Full Screen Display: requestWindowFeature (Window. FEATURE_NO_TITLE );

Screen Adaptation: sensor

Tween animation: animated effects are generated by constantly changing images (such as translation and scaling) of objects in a scenario.

Frame Animation: this is an image that can be prepared through sequential broadcasting.

Gif Animation: Gif Decoding-sequential playback

 

From Tyrone's column

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.