/ / Convertir el mapa de bits a imagen vista - Android, diseño de Android

conversión del mapa de bits a imageview - android, android-layout

He escrito mi propia vista personalizada, en la costumbrevista, hice un dibujo a mano alzada usando lienzo ... Después de eso, agregué la vista personalizada al diseño lineal ... cómo agregar la vista personalizada a la vista de imagen ... ayúdeme ... Gracias de antemano ...

Respuestas

7 para la respuesta № 1

Esta pregunta no está tan clara, pero si tiene un mapa de bits y desea dibujarlo en un ImageView, simplemente llame ImageView.setImageBitmap ().


0 para la respuesta № 2

En este caso, puede convertir su vista personalizada a Bitmap imagen utilizando el siguiente fragmento de código:

public static Bitmap getBitmapFromView(View view) {
//Define a bitmap with the same size as the view
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),Bitmap.Config.ARGB_8888);
//Bind a canvas to it
Canvas canvas = new Canvas(returnedBitmap);
//Get the view"s background
Drawable bgDrawable =view.getBackground();
if (bgDrawable!=null)
//has background drawable, then draw it on the canvas
bgDrawable.draw(canvas);
else
//does not have background drawable, then draw white background on the canvas
canvas.drawColor(Color.WHITE);
// draw the view on the canvas
view.draw(canvas);
//return the bitmap
return returnedBitmap;
}

Luego puede agregar un mapa de bits a la vista de imagen usando el siguiente método:

imageview.setBitmapImage(returnedBitmap);