android imageView 显示ico格式图标文件,androidimageview
投稿于 被查看 44298 次 评论:70
android imageView 显示ico格式图标文件,androidimageview
imageview显示ico图标需要兜一个圈子在此贴出代码 此代码感谢 @鉴客 的那几行代码,我只是将它们组装在了一起1.[Java]代码
String p = Environment.getExternalStorageDirectory() + "/ico/ifeng.ico"; String p2 = Environment.getExternalStorageDirectory() + "/ico/ifeng.png"; FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(p); fos = new FileOutputStream(p2); } catch (FileNotFoundException e) { e.printStackTrace(); } Bitmap bmp = BitmapFactory.decodeStream(fis); bmp.compress(Bitmap.CompressFormat.PNG, 0, fos); Drawable d = Drawable.createFromPath(p2); ImageView topleftimage = (ImageView) findViewById(R.id.topleftimage); topleftimage.setImageDrawable(d);
用户评论