Rushing to Daniel's Android: How the Learning interface is drawn in the program

Source: Internet
Author: User

Today saw a memory management software, the interface is all in the program to draw out, understand only to find that the original memory management software because the interface is constantly changing
So only in the program through the code to achieve, this will be designed to the view class in Android, directly on the code:

Import Android.os.Bundle;
Import android.app.Activity;
Import Android.content.Context;
Import Android.graphics.Canvas;
Import Android.graphics.Color;
Import Android.graphics.Paint;
Import Android.view.Menu;
Import Android.view.View;

public class Mainactivity extends Activity {

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (New MyView (this));

}

Private class MyView extends view{

Public MyView (Context context) {
Super (context);
TODO auto-generated Constructor stub
}
/* (Non-javadoc)
* @see Android.view.view#ondraw (Android.graphics.Canvas)
*/
@Override
protected void OnDraw (canvas canvas) {
TODO auto-generated Method Stub
Super.ondraw (canvas);
Paint Paint =new paint ();
Paint.setantialias (FALSE);

Paint.setcolor (Color.Blue);
Canvas.drawcircle (A.);
}

}

}
This is a simple drawing that draws a circle on the screen and shows the activity through Setcontentview (new MyView (This))

1. First of all we need to understand a few of these concepts, paint brush, canvas canvas, that is, this screen is the equivalent of a canvas canvases, you hold the paint

Draw what you want from the top.

2.paint There are many parameters, where Paint.setantialias (false), this is set whether the brush anti-aliasing, directly on, you can see the difference or

650) this.width=650; "title=" is not anti-aliasing. JPG "style=" Float:none; "src=" Http://s3.51cto.com/wyfs02/M00/54/13/wKiom1R3E3Tx1EorAABn1QHKeXw474.jpg "alt=" Wkiom1r3e3tx1eoraabn1qhkexw474.jpg "/>

650) this.width=650; "title=" anti-aliasing. JPG "style=" Float:none; "src=" Http://s3.51cto.com/wyfs02/M01/54/11/wKioL1R3E_fhkL7DAACB7wLx4SE447.jpg "alt=" Wkiol1r3e_fhkl7daacb7wlx4se447.jpg "/>



Very large, so we generally want to set this to Ture

3.canvas has a lot of graphics that can be called directly

Let's go ahead and write about it here today!!!!!!!!



Rushing to Daniel's Android: How the Learning interface is drawn in the program

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.