我正在尝试制作一个包含表情符号的旋转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 --它们不会被旋转,它们只是像旋转木马一样移动),但是我仍然不明白为什么会发生这种情况,或者表情符号的旋转(在第一张图片上)仅仅是因为硬件加速?
发布于 2017-03-30 11:31:17
好吧,我找不到解决这个非常烦人的问题的方法,所以我不得不破译一下。图像视图与旋转完美地工作。所以我基本上用图像视图做了所有的操作--并且用这个方法将它的图像从我想要的表情符号文本中设置出来:
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);https://stackoverflow.com/questions/37254577
复制相似问题