In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to analyze the use of the guide bee two-dimensional graphics library in Android development, I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
AndroidGraphics2DTutorial defines the main Activity of the application, so you can start writing each specific 2D drawing example. Different examples will try to use different UI controls: Menu,Content Menu,Dialog,Custom Dialog,Button and so on. The example uses the guide bee two-dimensional graphics library, the guide bee two-dimensional graphics library Graphics 2D API implements the graphics engine on the mobile platform (Java ME,Blackberry,iPhone,Android,Windows Phone), which can deal with a variety of basic graphics (Shape), path (Path), text (Texts), the right amount of fonts and images in a unified way. To put it simply, Graphics 2D API implements a similar two-dimensional graphics library API on the corresponding Java SE.
The main functions are as follows:
Support a variety of basic graphics: curves, rectangles, ellipses, etc.; support the drawing of arbitrary geometry
Support collision detection on graphics, style and images
Enhanced color support and color management
Control the quality of drawing
Fill, frame, all kinds of line drawing
Two-dimensional graphic transformation
Vector font
Show style from left to right, from right to left, from top to bottom
Anti-aliasing
Transparency support
Icons, and image drawing
In Android Concise Development tutorial 9: creating an Application Framework, we defined a base class, Graphics2DActivity, as the parent class of all sample Activity:
Public abstract class Graphics2DActivity extends Activity {protected Graphics2D graphics2D = SharedGraphics2DInstance.graphics2d; public void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.main);} protected abstract void drawImage (); public void onStart () {super.onStart (); drawImage ();}}
Where graphics2D is the drawing board object (Canvas) is represented by a two-dimensional array of integers of width x height. Each value of this array is an integer of 32. The format is ARGB, which represents transparency, red, green and blue, respectively. The drawing operation on the artboard (points, lines, polygons, fills, etc.) is to modify these color values.
GuidebeeGraphics2DSurfaceView or GuidebeeGraphics2DView can be used in R.layout.main as the display result of the artboard.
The abstract method protected abstract void drawImage (); is used to draw different content.
Modify com.pstreets.graphics2d.example.Colors to use the guide bee 2D graphics library to draw different colors, if you have used Java SE or .net Framework before, you will find that the API provided by the guide bee 2D graphics library is very similar to them, and the code is easy to understand.
Public class Colors extends Graphics2DActivity {protected void drawImage () {/ * The solid (full opaque) red color in the ARGB space * / Color redColor = new Color (0xffff0000); / * * The semi-opaque green color in the ARGB space (alpha is 0x78) * / Color greenColor = new Color (0x7800ff00true) / * The semi-opaque blue color in the ARGB space (alpha is 0x78) * / Color blueColor = new Color (0x780000ffje true); / * The semi-opaque yellow color in the ARGB space (alpha is 0x78) * / Color yellowColor = new Color (0x78ff00ff00true) / * The dash array * / int dashArray [] = {20,8}; graphics2D.clear (Color.WHITE); SolidBrush brush=new SolidBrush (redColor); graphics2D.fillOval (brush,30,60,80,80); brush=new SolidBrush (greenColor); graphics2D.fillOval (brush,60,30,80,80) Pen pen=new Pen (yellowColor,10,Pen.CAP_BUTT,Pen.JOIN_MITER,dashArray,0); brush=new SolidBrush (blueColor); graphics2D.setPenAndBrush (pen,brush); graphics2D.fillOval (null,90,60,80,80); graphics2D.drawOval (null,90,60,80,80);}}
Colors Activity is very simple. There is no UI other than View. Press "Back" to return the sample list to display UI.
After reading the above, have you mastered how to analyze the use of the guide bee 2D graphics library in Android development? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 219
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.