Android UI开发专题
- 格式:doc
- 大小:55.00 KB
- 文档页数:14
Android开发UI界面设计ON 六16 2011 IN ANDROID界面设计 BY ANDROID智能手机| NO COMMENTS已有1420位网友关注Android开发UI界面设计主要有两点:一是Android按钮(Button)的UI设计,二是:ListView以及GridView的UI设计。
按钮的状态:我们一般搞UI设计,按钮通常有三个状态:normal(正常状态);focus(焦点状态),pressed(按下状态)。
如下图所示:我们会在res/drawable目录下定义一个资源文件,比如我们本例中要用到的handle.xml,在里面定义三种状态,每种状态对应一张图片:代码如下:<?xml version=”1.0″ encoding=”utf-8″?><selector xmlns:android=”/apk/res/android”><item android:state_window_focused=”false” android:drawable=”@drawable/handle_normal” /><item android:state_focused=”true” android:drawable=”@drawable/handle_focused” /><item android:state_pressed=”true” android:drawable=”@drawable/handle_pressed” /></selector>而我们使用这个资源文件的用法只需要引用drawable里的资源文件(android:background=”@drawable/handle”)代码如下:<Buttonandroid:id=”@+id/handle”android:layout_width=”wrap_content”android:layout_height=”fill_parent”android:background=”@drawable/handle”/>Android中的层:看过《盗梦空间》的人都知道,梦境有多少层,而Android中也有层次之分,在Android中第一层”梦境”,我们可以认为是壁纸。
AndroidUI界面编程概览Android UI界面编程常用控件Android UI界面编程概览本文主要对Android UI 用户界面开放的一些基本概念,均不做深入讲解,但可以快速浏览Android开放经常涉及到的一些基本概念和要素。
一、界面元素1. 窗口:Activity应用程序中每个屏幕显示都通过继承和扩展基类Activity实现分类:基本Activity,带内容的Activity(如ListActivity)2. 对话框:Dialog一种显示于Activity之上的界面元素,由Activity管理,用于显示一些临时信息和功能,它比Activity开销小1) 常用对话框:AlertDialog:信息对话框DatePickerDialog,TimePickerDialog:时间日期选择对话框ProgressDialog:进度对话框还可以设置对话框内容为我们自定义的View2) 相关函数:onCreateDialog():创建对话框的实现showDialog():需要显示的时候调用onPrepareDialog():更改已有对话框时调用3. 菜单:Menu一种显示于Activity之上的界面元素,由Activity管理,用于提供用户一些额外的选项和设置1) 常用菜单:Options Menu:按Menu键时从屏幕底部滑出的菜单Context Menu:用户通过在按件上长按调出它Android UI界面编程常用控件Submenu:用于给菜单分类,可被添加到其它菜单上,不能添加到子菜单上2) 相关函数:onCreateOptionMenu():创建菜单(onCreateContextMenu…)onOptionsItemSelected():处理菜单项的单击事件onPrepareOptionsMenu():动态更新4. 可视化控件:ViewView是可视化控件的基类1) 常用控件:TextView, ImageViewButton, CheckBox, RadioButton, ImageButton, ToggleButtonAnalogClock, DigitalClockEditText, List…2) 数据绑定:adapteradapter将控件(如List, GridView)和复杂数据(如数据,键表)绑定起来5. 其它界面元素标题栏二、layout布局的实现设置控件在屏幕上如何排布1. LinearLayout:线性的布局方式最常用,上下或左右的添加控件2. GridView:网格布局控件按照顺序依次填到每个格子里就好了,使界面很整齐3. TableLayout:表格布局以行列形式管理子控件,每行为一个TableRow,TableRow可添加子控件4. AbsoluteLayout:绝对坐标布局可以让子元素指定准确的x/y坐标值,并显示在屏幕上。
Android UI界面编程简述ChateauAerlian布局菜单的生成对话框的生成UI事件处理在Android,有多种方法可以截取用户与应用程序之间的事件交互。
考虑到用户界面上的事件,可以通过用户操作的界面所对应的View对象来获取。
View类提供了相关的方法。
在构建界面布局时,会使用到View类,其中有一些公共的回调函数,对用户界面事件是有用的。
当对应的View 上有事件发生时,这些回调函数将被Android的Framework调用。
例如,一个View(属于一个Button)被触摸点击,onTouchEvent()方法将被调用。
为了去获取该事件,开发者必须扩展这个类,并且重载这个方法。
但是,扩展每一个View对象实例以便去获取事件,这样做是不实际的。
这就是为什么View类也包含一些嵌套的接口,该接口和回调函数一起使用,方便定义。
这些接口叫做事件监听,能通过他们来获取用户与界面的交互。
当经常地使用事件监听时,可能也会需要扩展一个View类,以便去构建一个用户自定义元素。
也许你希望去扩展一个Button类去做一些其他事情。
在该情况下,你将能够通过使用eventhandlers去定义缺省的事件行为。
事件监听一个事件监听是View类中的一个接口,其中包含一个单一的回调方法。
当View监听被注册并被用户操作所触发时,Android框架将调用这些方法。
OnClick()来自View.OnClickListener.,用户点击Item(Touch模式)、提起导航键、按下轨迹球、按下enter 键时触发。
OnLongClick()来自View.OnLongClickListener.,用户长按Item(Touch模式)、长按导航键、长按轨迹球、长按enter键。
OnFocueChange()来自View.OnFocusChangeListener.,用户使用轨迹球或者是导航键去移动光标。
OnKey()来自View.OnKeyListener,用户按下或者释放一个Key设备。
今天我们继续介绍Android平台底层绘图类的相关内容,在Android UI开发专题(一) 之界面设计中我们介绍了有关Android平台资源使用以及Bitmap相关类的操作,接下来将会以实例的方式给大家演示各种类的用处以及注意点。
今天我们继续了解android.graphics包中比较重要的绘图类。
一、android.graphics.Matrix有关图形的变换、缩放等相关操作常用的方法有:void reset() // 重置一个matrix对象。
void set(Matrix src) //复制一个源矩阵,和本类的构造方法Matrix(Matrix src) 一样boolean isIdentity() //返回这个矩阵是否定义(已经有意义)void setRotate(float degrees) //指定一个角度以0,0为坐标进行旋转void setRotate(float degrees, float px, float py) //指定一个角度以px,py为坐标进行旋转void setScale(float sx, float sy) // 缩放void setScale(float sx, float sy, float px, float py) //以坐标px,py进行缩放void setTranslate(float dx, float dy) //平移void setSkew (float kx, float ky, float px, float py) //以坐标px,py进行倾斜void setSkew (float kx, float ky) //倾斜二、android.graphics.NinePatchNinePatch是Android平台特有的一种非矢量图形自然拉伸处理方法,可以帮助常规的图形在拉伸时不会缩放,实例中Android开发网提示大家对于Toast的显示就是该原理,同时SDK中提供了一个工具名为Draw 9-Patch,有关该工具的使用方法可以参考我们经发布的Draw 9-Patch使用方法介绍一文。
Android 实验设计实验二:界面设计:控件与布局08计应 08386038 胡巍巍【目的】Android编程基础,UI设计。
【要求】1、了解Android编程原理2、掌握界面控件设计3、掌握控件的事件处理编程【原理】1.熟悉各种控件的基本功能常用控件包括:TextView,EditText,Button,ImageView:ImageButton,ProgressBar,Radio button:2.了解各种布局Layout的应用多种Layout: AbsoluteLayout FrameLayout GridViewLinearLayout ListLayout RadioGroupTableLayout ………【实验过程】新建一个Project,并对其布局文件进行简单修改。
1.New 一个 Android project:Project Name: Practice,Application name:Project,Build Target勾选Android 2.2,Package name:com.eoeAndroid.Practice ,Create Activity:Practice ,Min SDK Version:8. 然后点击Next→Finish。
2.Finish后,Eclipse Platform左边Package Explorer栏中出现了我们刚才新建的project。
根据实验要求在layout main.xml中修改布局文件(我选的是相对布局relative layout),增加所需控件。
分析实验要求后,对要求添加的控件按照从上到下,从左到右的顺序添加。
布局xml实现如下:<?xml version="1.0"encoding="utf-8"?><RelativeLayout xmlns:android="/apk/res/android"android:orientation="horizontal" //默认控件水平排列android:layout_width="fill_parent" //相对布局的有效范围android:layout_height="fill_parent"android:background="#ffffff"> //背景颜色<TextView android:id="@+id/text1" //第一个文本控件android:layout_width="wrap_content" //控件宽度和高度有文本决定android:layout_height="wrap_content"android:text="@string/hello"/>//文本内容:hello所定义的字符串<TextView android:id="@+id/text2" //第二个文本控件android:layout_width="wrap_content" //同上android:layout_height="wrap_content"android:layout_below="@id/text1"//这里实现text2布局在text1的下方android:text="Hello,It's Huweiwei's Android Project !"//内容android:textStyle="bold"/>//文本字体样式,这里是粗体<EditText android:id="@+id/ET1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@id/text2"android:hint="Input what you want to say to TA"android:shadowColor="#ff0000"/>//边框阴影眼测<TextView android:id="@+id/text3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/ET1"android:text="Do you miss Miss TA^0^?"android:textStyle="bold"/><RadioGroup android:layout_width="wrap_content"//这里定义了一对单项android:layout_height="wrap_content" //选择,水平排列android:checkedButton="@+id/RB1"android:orientation="horizontal"android:layout_below="@id/text3"android:id="@+id/menu"><RadioButton android:id="@+id/RB1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Yes!^0^)/"android:textStyle="normal"android:textColor="#000000"/><RadioButton android:id="@+id/RB2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textColor="#000000"android:text="No~(T_T)"android:textStyle="normal"/></RadioGroup><TextView android:id="@+id/text4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/menu"android:text="Button,Do you want to marry with ImageView?"android:textStyle="bold"/><ImageView android:id="@+id/IM1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/text4"android:src="@drawable/icon"/>//图像来源<Button android:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@id/IM1"//button1安置在IM1的左侧,并且android:layout_alignTop="@id/IM1"//与IM1并排android:text="Yes T do !"android:textColor="#0000ff"/><TextView android:id="@+id/text6"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/text4"android:layout_toRightOf="@id/button1"android:visibility="invisible"android:layout_marginTop="10dip" //在文本上方预留10dip的空间android:text="Congratulations!"android:textStyle="bold"/><TextView android:id="@+id/text5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/button1"android:visibility="invisible" //设置text5默认情况下不可见android:text="Years later their son was born~,It'sImageButton~"android:textStyle="bold"/><ImageButton android:layout_below="@+id/text5"android:id="@+id/ImageButton01"android:layout_width="wrap_content"android:layout_height="wrap_content"android:visibility="invisible"android:src="@drawable/icon"></ImageButton></RelativeLayout>以上完成了对各个控件的布局,由于是第一次使用xml文件进行布局工作,对控件的各种属性都不了解,因此我并没有采用拖拉的方法编写xml文件,而是一句句的编写,这虽然会花费相当长的时间,但我觉得这是值得的,因为在这个过程中,我知道了控件的每个属性的不同值决定控件怎样的特性,还有不同的控件之间的关系如何用他们的属性表示,这对以后的工作会有很大帮助的。
计算机编程知识:Android高级UI开发实践Android高级UI开发实践随着移动设备使用的普及,Android平台已经成为了全球最大的移动设备操作系统。
因此,Android开发者们需要借助各种先进的技术和工具,来提升他们的应用的用户体验,并更好地满足用户的需求。
本文将讨论Android高级UI开发实践,介绍一些最新和最流行的UI开发技术,帮助Android开发者们更好地开发高质量的应用。
1. Material DesignMaterial Design是一种现代化的UI设计语言,由Google在2014年推出。
Material Design采用简单,直观的设计,提供了更具有真实感的互动体验。
Android开发者们可以通过使用Material Design的设计模式和组件,来创建具有良好体验的UI。
2.合适的字体在Android应用中,字体的选择和使用非常重要。
合适的字体可以增强用户体验并提高应用的可读性。
开发者们需要在选择字体时考虑以下因素:字体的大小,字母的间距,字体的颜色。
还可以考虑使用一些现成的字体库,如Google Fonts和Typekit。
3.动画和过渡动画和过渡是Android UI开发中的一个重要方面。
适当的动画和过渡可以增强用户体验,并使应用在切换时看起来更加流畅。
Android开发者可以使用Android原生的过渡和动画API,或者使用第三方的库,如Lottie或Tween。
4.触摸反馈在Android应用中,触摸反馈可以使用户感觉更亲切,并提供更好的用户体验。
Android提供了很多内置的触摸反馈效果,例如水波纹和震动反馈。
此外,开发者们还可以选择使用自定义的触摸反馈效果,以更好地满足他们应用程序的需求。
5.简单但明了的设计在设计Android应用UI时,开发者们需要遵循“简约”的原则。
简单但明了的设计可以带来更好的用户体验,而不仅仅是美观的UI。
设计时应遵循合理的布局,颜色搭配,字体等原则。
Android UI基础知识一、Android UI组件的概述在Android应用程序开发过程中,主要就是对界面UI的设计与控制,android中的UI 元素包括:Activity、View、ViewGroup和布局。
Activity不是View但是包括View,View是常说的“组件”或者“控件”。
1、View在Andorid应用程序中,UI元素称为View,它们都继承了android.view.View类。
View 有众多的子类,包括ViewGroup、基础控件、高级控件和布局。
基础控件主要包括:Button、ImageButton、ToggleButton、TextView、RadioButton、CheckBox、ImageView、ProgressBar、SeekBar等。
2、ViewGroupandroid.view.ViewGroup类是android.view.View重要的子类,ViewGroup类通常叫做“容器”,它就是由个控件组成的复杂控件,因为它也是View类的子类,所以本身也是控件。
ViewGroup是高级控件的和布局的父类,高级控件是和布局与基础控件一样都是不指具体那个类,而是一类容器的总称。
高级控件都直接或者间接的继承了android.view.ViewGroup类,常用的高级控件主要包括:AutoCompleteTextView、Spinner、ListView、GridView、Gallery等。
3、布局管理布局是指导把各个UI元素在手机屏幕上进行布置。
常用的布局包括以下几个:1)FrameLayout(框架布局),通常也叫做帧布局。
2)LinerLayout(线性布局),让所有的UI无成为单一方向的布局。
3)AbsoluteLayout(绝对布局),让所有的UI元素准确的(x ,y)坐标值进行放置。
4)RelativeLayout(相对布局),将子元素的放置位置与其它元素的位置相关放置。
/cmdn/bbs/viewthread.php?tid=18736&page=1 #pid89255Android UI开发专题(一) 之界面设计近期很多网友对Android用户界面的设计表示很感兴趣,对于Android UI开发自绘控件和游戏制作而言掌握好绘图基础是必不可少的。
本次专题分10节来讲述,有关OpenGL ES相关的可能将放到以后再透露。
本次主要涉及以下四个包的相关内容:android.content.res 资源类android.graphics 底层图形类android.view 显示类android.widget 控件类一、android.content.res.Resources对于Android平台的资源类android.content.res.Resources可能很多网友比较陌生,一起来看看SDK上是怎么介绍的吧,Contains classes for accessing application resources, such as raw asset files, colors, drawables, media or other other files in the package, plus important device configuration details (orientation, input types, etc.) that affect how the application may behave.平时用到的二进制源文件raw、颜色colors、图形drawables和多媒体文件media的相关资源均通过该类来管理。
int getColor(int id) 对应res/values/colors.xmlDrawable getDrawable(int id) 对应res/drawable/XmlResourceParser getLayout(int id) 对应res/layout/String getString(int id) 和CharSequence getText(int id) 对应res/values/strings.xmlInputStream openRawResource(int id) 对应res/raw/void parseBundleExtra (String tagName, AttributeSet attrs, Bundle outBundle) 对应res/xml/ String[] getStringArray(int id) res/values/arrays.xmlfloat getDimension(int id) res/values/dimens.xml二、android.graphics.Bitmap作为位图操作类,Bitmap提供了很多实用的方法,常用的我们总结如下:boolean compress(pressFormat format, int quality, OutputStream stream) 压缩一个Bitmap对象根据相关的编码、画质保存到一个OutputStream中。
其中第一个压缩格式目前有JPG和PNGvoid copyPixelsFromBuffer(Buffer src) 从一个Buffer缓冲区复制位图像素void copyPixelsToBuffer(Buffer dst) 将当前位图像素内容复制到一个Buffer缓冲区我们看到创建位图对象createBitmap包含了6种方法在目前的Android 2.1 SDK中,当然他们使用的是API Level均为1,所以说从Android 1.0 SDK开始就支持了,所以大家可以放心使用。
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) //创建一个可以缩放的位图对象final int getHeight() 获取高度final int getWidth() 获取宽度final boolean hasAlpha() 是否有透明通道void setPixel(int x, int y, int color) 设置某像素的颜色int getPixel(int x, int y) 获取某像素的颜色,android开发网提示这里返回的int型是color 的定义三、android.graphics.BitmapFactory作为Bitmap对象的I/O类,BitmapFactory类提供了丰富的构造Bitmap对象的方法,比如从一个字节数组、文件系统、资源ID、以及输入流中来创建一个Bitmap对象,下面本类的全部成员,除了decodeFileDescriptor外其他的重载方法都很常用。
static Bitmap decodeByteArray(byte[] data, int offset, int length) //从字节数组创建static Bitmap decodeByteArray(byte[] data, int offset, int length, BitmapFactory.Options opts) static Bitmap decodeFile(String pathName, BitmapFactory.Options opts) //从文件创建,路径要写全static Bitmap decodeFile(String pathName)static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, BitmapFactory.Options opts) //从输入流句柄创建static Bitmap decodeFileDescriptor(FileDescriptor fd)static Bitmap decodeResource(Resources res, int id) //从Android的APK文件资源中创建,android123提示是从/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) //从一个输入流中创建static Bitmap decodeStream(InputStream is, Rect outPadding, BitmapFactory.Options opts)四、android.graphics.Canvas从J2ME MIDLET时我们就知道Java提供了Canvas类,而目前在Android平台中,它主要任务为管理绘制过程,The Canvas class holds the "draw" calls. To draw something, you 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 thecolors and styles for the drawing).该类主要提供了三种构造方法,分别为构造一个空的Canvas、从Bitmap中构造和从GL对象中创建,如下Canvas()Canvas(Bitmap bitmap)Canvas(GL gl)同时Canvas类的一些字段保存着重要的绘制方法定义,比如Canvas.HAS_ALPHA_LAYER_SA VE_FLAG 保存时需要alpha层,对于Canvas类提供的方法很多,每个都很重要,下面我们一一作介绍boolean clipPath(Path path)boolean clipPath(Path path, Region.Op op)boolean clipRect(float left, float top, float right, float bottom)boolean clipRect(Rect rect)boolean clipRect(float left, float top, float right, float bottom, Region.Op op)boolean clipRect(Rect rect, Region.Op op)boolean clipRect(RectF rect)boolean clipRect(RectF rect, Region.Op op)boolean clipRect(int left, int top, int right, int bottom)boolean clipRegion(Region region, Region.Op op)boolean clipRegion(Region region)void concat(Matrix matrix)void drawARGB(int a, int r, int g, int b)void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint) void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint)void drawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, Paint paint)void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)void drawBitmap(Bitmap bitmap, float left, float top, Paint paint)void drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint)void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors, int colorOffset, Paint paint)void drawCircle(float cx, float cy, float radius, Paint paint)void drawColor(int color)void drawColor(int color, PorterDuff.Mode mode)void drawLine(float startX, float startY, float stopX, float stopY, Paint paint)void drawLines(float[] pts, Paint paint)void drawLines(float[] pts, int offset, int count, Paint paint)void drawOval(RectF oval, Paint paint)void drawPaint(Paint paint)void drawPath(Path path, Paint paint)void drawPicture(Picture picture, RectF dst)void drawPicture(Picture picture, Rect dst)void drawPicture(Picture picture)void drawPoint(float x, float y, Paint paint)void drawPoints(float[] pts, int offset, int count, Paint paint)void drawPoints(float[] pts, Paint paint)void drawPosText(char[] text, int index, int count, float[] pos, Paint paint)void drawPosText(String text, float[] pos, Paint paint)void drawRGB(int r, int g, int b)void drawRect(RectF rect, Paint paint)void drawRect(float left, float top, float right, float bottom, Paint paint)void drawRect(Rect r, Paint paint)void drawRoundRect(RectF rect, float rx, float ry, Paint paint)void drawText(String text, int start, int end, float x, float y, Paint paint)void drawText(char[] text, int index, int count, float x, float y, Paint paint)void drawText(String text, float x, float y, Paint paint)void drawText(CharSequence text, int start, int end, float x, float y, Paint paint)void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint)void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset, float vOffset, Paint paint)void drawVertices(Canvas.VertexMode mode, int vertexCount, float[] verts, int vertOffset, float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, int indexOffset, int indexCount, Paint paint)static void freeGlCaches()boolean getClipBounds(Rect bounds)final Rect getClipBounds()int getDensity()DrawFilter getDrawFilter()GL getGL()int getHeight()void getMatrix(Matrix ctm)final Matrix getMatrix()int getSaveCount()int getWidth()boolean isOpaque()boolean quickReject(Path path, Canvas.EdgeType type)boolean quickReject(float left, float top, float right, float bottom, Canvas.EdgeType type) boolean quickReject(RectF rect, Canvas.EdgeType type)void restore()void restoreToCount(int saveCount)final void rotate(float degrees, float px, float py)void rotate(float degrees)int save()int save(int saveFlags)int saveLayer(float left, float top, float right, float bottom, Paint paint, int saveFlags)int saveLayer(RectF bounds, Paint paint, int saveFlags)int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, int saveFlags) int saveLayerAlpha(RectF bounds, int alpha, int saveFlags)final void scale(float sx, float sy, float px, float py)void scale(float sx, float sy)void setBitmap(Bitmap bitmap)void setDensity(int density)void setDrawFilter(DrawFilter filter)void setMatrix(Matrix matrix)void setViewport(int width, int height)void skew(float sx, float sy)void translate(float dx, float dy)五、android.graphics.Color有关Android平台上表示颜色的方法有很多种,Color提供了常规主要颜色的定义比如Color.BLACK和Color.GREEN等等,我们平时创建时主要使用以下静态方法static int argb(int alpha, int red, int green, int blue) 构造一个包含透明对象的颜色static int rgb(int red, int green, int blue) 构造一个标准的颜色对象static int parseColor(String colorString) 解析一种颜色字符串的值,比如传入Color.BLACK本类返回的均为一个整形类似绿色为0xff00ff00,红色为0xffff0000。