Issue
I'm trying to get an image from the folder /drawable but I receive null when api > 19. Does anyone know what the problem is?
All images I use are vectors.
dog.setImagen(BitmapFactory.decodeResource(getResources(), R.drawable.dog));
Thanks in advance
Solution
I have solved my problem with this code.
private Bitmap getBitmap(Drawable vectorDrawable) {
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
vectorDrawable.draw(canvas);
return bitmap;
}
Thanks everyone!
Answered By - eligonz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.