Android UI Development Topic (i) interface design

Source: Internet
Author: User
Tags config file system final resource

recently, many netizens are interested in the design of the Android user interface, which is essential for the development of the Android UI to develop a self drawing Control and game making. This topic is divided into 10 sections to tell, about OpenGL ES related may be put to later revealed. This is mainly related to the following four packages:

Android.content.res Resource Class

Android.graphics underlying Graphics class

Android.view Display Class

Android.widget Control class

First, android.content.res.Resources

For the Android platform resource class Android.content.res.Resources may be a lot of friends unfamiliar, together to see how the SDK is introduced on it, Contains classes for accessing application Resources, such as raw asset files, colors, drawables, media or other other files in the package, plus important device co Nfiguration details (orientation, input types, etc.) that affect how the application may behave. Binary source files used at ordinary times raw, color colors, graphics Drawables and multimedia file media related resources are managed through this class.

int getcolor (int id) corresponds to Res/values/colors.xml

drawable getdrawable (int id) corresponds to res/drawable/

Xmlresourceparser getlayout (int id) corresponds to res/layout/

String getString (int id) and charsequence getText (int id) correspond res/values/strings.xml

InputStream openrawresource (int id) corresponds to res/raw/

void Parsebundleextra (String tagName, AttributeSet attrs, Bundle outbundle) corresponds to res/xml/

String[] Getstringarray (int id) res/values/arrays.xml

float getdimension (int id) res/values/dimens.xml

Second, Android.graphics.Bitmap

As a bitmap operation class, Bitmap provides a number of practical methods, commonly used in our summary as follows:

Boolean compress (bitmap.compressformat format, int quality, OutputStream stream) compresses a Bitmap object based on the associated encoding, The picture is saved in a outputstream. Where the first compression format currently has JPG and PNG

void Copypixelsfrombuffer (buffer src) replicates the bit image element from a buffer buffer

void Copypixelstobuffer (buffer dst) copies the current bit-image content to a buffer cache

We see the creation of Bitmap objects CreateBitmap contains 6 methods in the current Android 2.1 SDK, of course, they are using API level is 1, so that is supported from the Android 1.0 SDK, so you can be assured to use.

Static Bitmap CreateBitmap (Bitmap src)

Static Bitmap CreateBitmap (int[] colors, int width, int height, bitmap.config Config)

Static Bitmap CreateBitmap (int[] colors, int offset, int stride, int width, int height, bitmap.config Config)

Static Bitmap CreateBitmap (Bitmap source, int x, int y, int width, int height, Matrix m, Boolean filter)

static Bitmap createbitmap (int width, int height, bitmap.config Config)

Static Bitmap CreateBitmap (Bitmap source, int x, int y, int width, int height)

Static Bitmap Createscaledbitmap (Bitmap src, int dstwidth, int dstheight, Boolean filter)//Create a bitmap object that can be scaled

Final int getheight () get height

Final int getwidth () Get width

Final Boolean Hasalpha () whether there is a transparent channel

void SetPixel (int x, int y, int color) sets the color of a pixel

int getpixel (int x, int y) gets the color of a pixel, the Android development network prompts you to return the int type is the definition of color

Third, Android.graphics.BitmapFactory

As an I/O class for the bitmap object, the Bitmapfactory class provides a rich way to construct bitmap objects, such as creating a Bitmap object from a byte array, file system, resource ID, and input stream, with all the members of this class Other overloaded methods, except Decodefiledescriptor, are very common.

Static Bitmap Decodebytearray (byte[] data, int offset, int length)//create from byte array

Static Bitmap Decodebytearray (byte[] data, int offset, int length, bitmapfactory.options opts)

Static Bitmap DecodeFile (String pathName, bitmapfactory.options opts)//created from file, path to write full

Static Bitmap DecodeFile (String pathName)

Static Bitmap Decodefiledescriptor (FileDescriptor fd, Rect outpadding, bitmapfactory.options opts)//create from input stream handle

Static Bitmap Decodefiledescriptor (FileDescriptor FD)

The static Bitmap Decoderesource (resources res, int ID)//is created from the Android apk file resource, android123 prompted from/res/drawable

Static Bitmap Decoderesource (resources res, int ID, bitmapfactory.options opts)

Static Bitmap Decoderesourcestream (resources res, typedvalue value, InputStream is, Rect pad, bitmapfactory.options opts)

Static Bitmap Decodestream (InputStream is)//created from an input stream

Static Bitmap Decodestream (InputStream is, Rect outpadding, Bitmapfactory.options opts)

Four, Android.graphics.Canvas

We knew from J2ME MIDlet that Java provided the Canvas class, and that it was currently in the Android platform, the main task was to manage the drawing process, the Canvas class holds the "draw" calls. To draw something, your need 4 basic components:a Bitmap to hold the pixels, A Canvas to host the draw calls (writing into The bitmap), a drawing primitive (e.g. Rect, Path, Text, bitmap), and a paint (to describe the colors and styles for the Drawing).

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.