这是Drawable.createFromStream的第二个参数的含义()方法?
从Android的API的我只得到:
公共静态绘制对象createFromStream(InputStream的是,字符串源名)
从InputStream创建绘制
在我看过我看到他们用字符串SRC的所有实例:是的目录,其中绘制的缓存名,相对于我的应用程序的根目录
一个并行的问题:我应该在哪里找到的Android核心源(例如Drawable.createFromStream()方法...的),以避免这种无聊的问题,在未来
? 解决方案这是基本没用
根据Froyo源时,它是从资源创建九个补片图像时使用,但创建常规位图时不 852私有静态绘制对象drawableFromBitmap(资源资源,位图BM,byte []的NP,
853矩形垫,弦乐源名){
854
855如果(NP!= NULL){
856回新NinePatchDrawable(RES,BM,NP,垫,源名);
857}
858
859回新BitmapDrawable(RES,BM);
860}
您遵循绘制对象code路线:
createFromStream
返回:
返回createFromResourceStream(NULL,NULL,是,源名,NULL);
这反过来使用:
返回drawableFromBitmap(RES,BM,NP,垫,源名);
(NP来自位图#getNinePatchChunk();
),这就要求:
返回新NinePatchDrawable(RES,BM,NP,垫,源名);
公共类NinePatch
创建从一个绘制投影 位图到九补丁。
参数
位图描述的修补程序的位图。
块描述底层怎么位的9补丁数据块 被分开,并绘制。
源名源位图的名称。 可能为空
Which is the meaning of the second parameter of Drawable.createFromStream() method?
From Android APIs I only get:
public static Drawable createFromStream (InputStream is, String srcName)
Create a drawable from an inputstream
In all examples I have read I see they use the string "src": is it the name of the directory where the drawable is cached, relative to my application's root dir?
One parallel question: where am I supposed to find Android core sources (for example of Drawable.createFromStream() method...), to avoid such silly questions, in future?
解决方案It's basically useless:
Based on Froyo source, it is used when creating nine-patch images from the resource, but not when creating a regular Bitmap:
852 private static Drawable drawableFromBitmap(Resources res, Bitmap bm, byte[] np,
853 Rect pad, String srcName) {
854
855 if (np != null) {
856 return new NinePatchDrawable(res, bm, np, pad, srcName);
857 }
858
859 return new BitmapDrawable(res, bm);
860 }
You get there by following the Drawable code:
createFromStream
returns:
return createFromResourceStream(null, null, is, srcName, null);
which in turn uses:
return drawableFromBitmap(res, bm, np, pad, srcName);
(np comes from Bitmap#getNinePatchChunk();
) and this calls:
return new NinePatchDrawable(res, bm, np, pad, srcName);
public class NinePatch
Create a drawable projection from a bitmap to nine patches.
Parameters:
bitmap The bitmap describing the patches.
chunk The 9-patch data chunk describing how the underlying bitmap is split apart and drawn.
srcName The name of the source for the bitmap. Might be null.
上一篇:什么是相当于一个JavaScript的setInterval / setTimeout的在Android的/ Java的?setInterval、JavaScript、setTimeout、Java