I want to get the bitmap that is drawn when a textview is displayed but without displaying the textview in the activity. something like this:
TextView t = new TextView(this);
t.forceToDrawItself();
Bitmap b=t.getViewBitmap();
how is this possible?
View#draw(Canvas)will draw the entire view into the givenCanvas. You can use the constructorCanvas(Bitmap)to create a Canvas that draws into the givenBitmap.Create a bitmap of the desired size with
Bitmap#createBitmap(int, int, Bitmap.Config), wrap it in a canvas, and pass it to your view’sdrawmethod.