欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

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);

用户评论