由于Android的 icon 四周圆角裁剪时为透明所以在分享到微信和QQ好友中呈现黑边。

代码解决办法

    Bitmap bmp = BitmapFactory.decodeResource(instance.getResources(),R.drawable.icon);    UMImage img = new UMImage(m_Context, changeColor(bmp));    //bitmap中的透明色用白色替换    public static Bitmap changeColor(Bitmap bitmap) {        if (bitmap == null) {            return null;        }        int w = bitmap.getWidth();        int h = bitmap.getHeight();        int[] colorArray = new int[w * h];        int n = 0;        for (int i = 0; i < h; i++) {            for (int j = 0; j < w; j++) {                int color = getMixtureWhite(bitmap.getPixel(j, i));                colorArray[n++] = color;            }        }        return Bitmap.createBitmap(colorArray, w, h, Bitmap.Config.ARGB_8888);    }    //获取和白色混合颜色     private static int getMixtureWhite(int color) {        int alpha = Color.alpha(color);        int red = Color.red(color);        int green = Color.green(color);        int blue = Color.blue(color);        return Color.rgb(getSingleMixtureWhite(red, alpha), getSingleMixtureWhite(green, alpha),                getSingleMixtureWhite(blue, alpha));    }    // 获取单色的混合值     private static int getSingleMixtureWhite(int color, int alpha) {        int newColor = color * alpha / 255 + 255 - alpha;        return newColor > 255 ? 255 : newColor;    }    

更多相关文章

  1. Gson 自动过滤null 解决方案。
  2. Android(安卓)关于手机基本信息的获得
  3. android 获取应用程序包名,图标,入口Activity类
  4. Android(安卓)-- 程序判断手机ROOT状态,获取ROOT权限
  5. android6.0获取通讯录权限
  6. android之TypedArray
  7. MAC和Windows Android(安卓)Studio获取SHA1值
  8. 使用Android(安卓)Camera2 API获取YUV数据
  9. Android实用技巧之adb命令:ADB命令大全

随机推荐

  1. Android项目结构和HelloWorld
  2. Android——自定义View(学习Android开发
  3. 利用AccessibilityService实现“微信红包
  4. Android关机和重启的调用代码
  5. android native crash日志解析
  6. Android(安卓)-- ListView与Adapter
  7. Android(安卓)Studio 在调试模式下查看不
  8. 最新历史版本 :Android(安卓)Bluetooth
  9. Android(安卓)中不同的系统版本隐藏和显
  10. 在Android(安卓)Studio中进行单元测试和U