The difference between the two images is that the original image is produced using a LAYER_TYPE_HARDWARE
layer. When you set a shadow layer on text using this layer type, the blur is created by the graphics processor on a texture.
See this article on View layers for details.
The captured image on the other hand is created by rendering into a bitmap, which is essentially the same as using LAYER_TYPE_SOFTWARE
. Since the blur is no longer created by the graphics processor, there is no guarantee that it will look the same.
You can experiment with it. Add code to force software rendering:
tv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
tv.setShadowLayer(20, 0, 0, Color.BLACK);
After you do this, the two images will look the same.
If you would like both images to look more like your original image with hardware blur, you can adjust the blur radius:
tv.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
tv.setShadowLayer(8, 0, 0, Color.BLACK);
If you would like to get results exactly like the original, by capturing a bitmap of the hardware-rendered image, it must be possible but I don't know an easy way. You might have to rewrite the app using OpenGL to get access to the underlying graphics buffers.