android从文件path中绘制

我有一个forms为“e:\ … \ xxx.jpg”的文件pathstring。我如何从中创build一个drawable?

你可以像这样从一个stringpath创build一个Drawable或者Bitmap:

String pathName = "/path/to/file/xxx.jpg"; Drawable d = Drawable.createFromPath(pathName); 

对于位图:

 String pathName = "/path/to/file/xxx.jpg"; bitmap b = BitmapFactory.decodeFile(pathName); 
Interesting Posts