android 绘图的基本知识

1。定义颜色的几种格式:A color value specifies an RGB value with an alpha channel, which can be used in various places such as specifying a solid color for a Drawable or the color to use for text. It always begins with a # character and then is followed by the alpha-red-green-blue information in one of the following formats: #RGB, #ARGB, #RRGGBB or #AARRGGBB.

2。安卓中的原生资源:openRawResource()方法如此描述

InputStream android.content.res.Resource.openRawResource(int id)

Open a data stream for reading a raw resource. This can only be used with resources whose value is the name of an asset files -- that is, it can be used to open drawable, sound, and raw resources; it will fail on string and color resources.

 打开数据流去读原生资源,该方法仅用于读文件夹的名称为原生资源文件名的名称。也就是说, 它只能用于打开 drawable,sound,raw资源文件夹,它不能打开string或者color资源。
从这里看出res中的原生资源有三个drawable, sound,raw.【注1】
3. paint.setAlpha(0x80);/设置颜色透明度为十六进制80(半透明),0x00全透明,0xFF

【注1】android 中的资源文件asset与res
    今天发现,在创建一个Android工程的时候,和src源文件夹并列的有两个文件夹,分别是res和assets。这两个文件夹是用来保存资源文件的,然而在这两个资源文件中保存的文件有所不同。
    在assets中保存的文件一般是原生的文件,通常很少用到,例如一个MP3文件,Android程序不能直接访问,必须通过AssetManager类以二进制流的形式来读取。而Res文件夹中的资源可以通过R资源类直接访问,经常使用。同样在res文件夹下还有一个文件夹raw也是用来存放原生文件的。
    在android中使用Asset或者res/raw时都要经过Asset Manager,使用这两种资源提供方式时,必须要注意文件大小。经过调试发 现,Asset或者res/raw中的资源文件的UNCOMPRESS_DATA_MAX取值为1048576字节,也就是最大为未压缩1MB。否则会在logcat下看到获取到Debug类型的信息,04-09 02:48:51.220: DEBUG/asset(10734): Data exceeds UNCOMPRESS_DATA_MAX (1905341 vs 1048576)可以看到接下产生了一个系统的错误,System.err,会发生java.io.IOException的异常。

你可能感兴趣的:(android)