WEB开发网
开发学院手机开发Android 开发 Android 画图学习总结类的简介 阅读

Android 画图学习总结类的简介

 2010-05-29 03:03:00 来源:WEB开发网   
核心提示:首先,如何获取 res 中的资源数据包package:android.content.res主要类:ResourcesAndroid SDK中的简介:Class for accessing an application’s resources.Class for accessing an application’s r

首先,如何获取 res 中的资源

数据包package:android.content.res

主要类:Resources

Android SDK中的简介:Class for accessing an application’s resources.Class for accessing an application’s resources. This sits on top of the asset manager of the application (accessible through getAssets()) and provides a higher-level API for getting typed data from the assets.

其主要接口按照功能,划分为以下三部分:

getXXXX()

例如:

int getColor(int id)

Drawable getDrawable(int id)

String getString(int id)直接获取res中存放的资源

InputStream openRawResource(int id)获取资源的数据流,读取资源数据

void parseBundleExtras(

XmlResourceParser parser, Bundle outBundle)从XML文件中获取数据

Resource为每种资源提供了相应的接口来获取这种资源,除了可以直接获取资源外,还额外提供了以数据流的方式获取资源,这在以后的应用程序开发中会经常使用,那么如何获取Resources了,如下:Resources r = this.getContext().getResources();

其次,如何获取资源中的画图对象

数据包package:android.graphics.drawable

主要类:Drawable

Android SDK中的简介:A Drawable is a general abstraction for “something that can be drawn.” Most often you will deal with Drawable as the type of resource retrieved for drawing things to the screen; the Drawable class provides a generic API for dealing with an underlying visual resource that may take a variety of forms.

看了以上简介,发现Drawable是个virtual class,具体如何画图,需要具体分析Drawable的子类,例如:BitmapDrawable

Android SDK中的简介:A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a BitmapDrawable from a file path, an input stream, through XML inflation, or from a Bitmap object. It can be defined in an XML file with the element.

其主要接口如下:

BitmapDrawable()

1 2 3  下一页

Tags:Android 画图 学习

编辑录入:coldstar [复制链接] [打 印]
赞助商链接