Skip to content

Instantly share code, notes, and snippets.

@xmaihh
Last active December 28, 2018 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xmaihh/5176e08813923f4716a5fb57c920e0bd to your computer and use it in GitHub Desktop.
Save xmaihh/5176e08813923f4716a5fb57c920e0bd to your computer and use it in GitHub Desktop.
图片Base64

Android中ImageView加载Base64图片其实非常简单,并不需要引入第三方库,方法如下:

import android.util.Base64;

代码片段

String base64 = "data:image/png;base64, x.xx.x.xx..."
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
imageView.setImageBitmap(decodedByte);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment