我如何截取带有表情符号的旋转 TextView 的屏幕截图?

How can i take screenshot of rotated TextView with emoji?

我正在尝试制作包含表情符号图标的旋转 TextView 的屏幕截图。但是在生成的位图中,我看到表情符号没有旋转!为什么会这样?如何使用旋转的表情符号制作屏幕截图?

我的期望:

这就是我得到的:

我正在使用此方法获取视图的屏幕截图:

layout.setDrawingCacheEnabled(true);
layout.buildDrawingCache();
Bitmap bitmap = null;
if (layout.getDrawingCache() != null)
    bitmap = layout.getDrawingCache().copy(Bitmap.Config.ARGB_8888, false);
layout.setDrawingCacheEnabled(false);
layout.destroyDrawingCache();

更新: 正如我想的那样,如果我设置 textView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 那么即使在 TextView 中表情符号也不会旋转(如果你旋转 TextView - 它们不会旋转,它们只会像旋转木马一样移动),但我仍然不真的不明白为什么会这样,或者表情符号的旋转(在第一张图片上)只是因为硬件加速?

好吧,我找不到解决这个非常烦人的问题的方法,所以我不得不稍微修改一下。 imageviews 与旋转完美配合。 所以我基本上使用图像视图进行所有操作 - 并使用此方法将其图像设置为我想要的表情符号文本:

private Bitmap generateBitmapFromText(int size, String res) {
    TextView tv = new TextView(getContext());
    tv.setText(res);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, 150f);
    tv.setTextColor(0xffffffff);
    tv.measure(size, size);
    int questionWidth = tv.getMeasuredWidth();
    int questionHeight = tv.getMeasuredHeight();
    Bitmap bitmap = Bitmap.createBitmap(questionWidth, questionHeight, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(bitmap);
    tv.layout(0, 0, questionWidth, questionHeight);
    tv.draw(c);
    return bitmap;
}

然后我打电话给

    Bitmap bitmap = generateBitmapFromText(stickersStartingSize, res);
    imageview.setImageBitmap(bitmap);