Prueba esto:
privado takeScreenShot vacío ()
{
Ver u = ((Actividad) mContext) .findViewById (R.id.scroll);
HorizontalScrollView z = (HorizontalScrollView) ((Actividad) mContext) .findViewById (R.id.scroll);
int totalHeight = z.getChildAt (0) .getHeight ();
int totalWidth = z.getChildAt (0) .getWidth ();
- Cómo ser un desarrollador de aplicaciones de Android
- Cómo llamar el método de una aplicación de Android de forma remota
- ¿Cuál es el mejor sitio para aprender Android?
- ¿Qué herramientas necesito para el desarrollo de Android?
- ¿Es suficiente un curso acelerado de Java para comenzar a desarrollar aplicaciones de Android?
Mapa de bits b = getBitmapFromView (u, totalHeight, totalWidth);
// Guardar mapa de bits
Cadena extr = Environment.getExternalStorageDirectory () + “/ Folder /”;
String fileName = “report.jpg”;
Archivo myPath = nuevo archivo (extr, fileName);
FileOutputStream fos = null;
tratar {
fos = nuevo FileOutputStream (myPath);
b.compress (Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush ();
fos.close ();
MediaStore.Images.Media.insertImage (mContext.getContentResolver (), b, “Pantalla”, “pantalla”);
} catch (FileNotFoundException e) {
// TODO Bloque de captura generado automáticamente
e.printStackTrace ();
} catch (Excepción e) {
// TODO Bloque de captura generado automáticamente
e.printStackTrace ();
}
}
mapa de bits público getBitmapFromView (Vista de vista, int totalHeight, int totalWidth) {
Bitmap returnBitmap = Bitmap.createBitmap (totalWidth, totalHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas (returnBitmap);
Drawable bgDrawable = view.getBackground ();
if (bgDrawable! = nulo)
bgDrawable.draw (lienzo);
más
canvas.drawColor (Color.WHITE);
view.draw (lienzo);
return returnBitmap;
}
También verifique esto: ¿Convertir todo el contenido de un ScrollView a un mapa de bits?