1. Java.lang.Math class constants and methods:

Math.pi records PI, math.e records E’s constant math.abs calculates the absolute value math.sin, sine, inverse sine, math.asin, inverse cosine, math.acos, inverse cosine, math.tan, tangent Atan arctangent function & NBSP; The arctangent function of math.atan2 quotients math.todegrees converts radians to angles math.toradians angles convert radians toRadians math.ceil gets the largest integer that is not less than a certain number. Math.floor gets the largest integer that is not greater than a certain number

For example: math.floor (12.7) =12.0

Math. Ceil (12.7) = 13.0

Ceil () is the ceiling, which is rounded up. Floor is the floor, rounded down. Round is a round.

SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT: SQRT

Math.sqrt(x) : square root math.pow (x,y) : = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Math.random Returns a random number between 0 and 1

Java.math. BigInteger(large integer) : BigInteger bi1=new BigInteger(“1234567890123456890”); java.math.BigInteger(large integer) : BigInteger bi1=new BigInteger(“1234567890123456890”); BigInteger bi2=BigInteger.valueOf(123L); bi1=bi1.add(bi2); //b1+b2 bi1=bi1.multiply(bi2); //b1*b2 bi1=bi1.subtract(bi2); //b1-b2 bi1=bi1.divide(bi2); // b1/b2

Java.math. BigDecimal(large float): BigDecimal bd = new BigDecimal(“3.1415926”); bd = bd.setScale(2,BigDecimal.ROUND_DOWN); // Take 3.1415926 after the decimal point


2.Java obtains random numbers

Random numbers are widely used in practice, such as generating a fixed length string or number. Or generate a number of arbitrary length, or perform an analog random selection, and so on. Java provides the most basic tools to help developers do all of this.

2.1 Java random number generation method








2.2. Description of the Random class API













































2.3. Instructions for using Random Class




































3.Color

1. The common expression method of color

There are four common ways to represent colors in Android:

(1) int color = color.blue;

(2) int color = color.argb (150,200,0,100);

Int color = color.parsecolor (“# FFFFFF “); ,0,100 (150200);

(4) Define colors in XML files;

2. Color constants and the colors they represent

In practical application, we commonly use the following colors, whose color constants and their colors are as follows:

Color. BLACK BLACK

Color, GREEN, GREEN

Color. BLUE BLUE

Color. LTGRAY light grey

Color. CYAN turquoise

Color. The MAGENTA red and purple

Color. DKGRAY film

Color. RED RED

Color. YELLOW, YELLOW

Color TRANSPARENT TRANSPARENT

Color. GRAY, GRAY

Color. WHITE WHITE

Class 4. Paint is introduced

Paint is an important part of the drawing process. Brushes store information such as colors and styles, and specify how to draw text and graphics. There are many methods for setting brush objects.

1. Graph drawing


















































2. Text drawing



























5.Canvas class

Once the brush properties are set, you also need to draw the image onto the canvas. Canvas class can be used to draw various graphics, such as drawing straight lines, rectangles, circles and so on. The methods of Canvas to draw common graphics are as follows:

DrawLine: canvas. DrawLine (float startX, float startY, float stopX, float stopY, Paint Paint);

DrawRect (float left, float top, float right, float bottom, Paint Paint);

DrawCircle: Canvas. drawCircle(float cx, float cy, float radius, Paint Paint);

DrawText (String text, float x, float y, Paint Paint);

DrawBirmap (Bitmap Bitmap, float left, float top, Paint Paint);


6. Bitmap and BitmapFactory











1. Use BitmapDrawable











Bitmap provides static methods for creating Bitmap objects (to name just a few) :














3. Obtain the Bitmap object by parsing the resource file, here we need to use the BitmapFactory utility class, which provides the following methods: