How can i take screenshot of rotated TextView with emoji?

☆樱花仙子☆ 提交于 2019-12-06 07:32:37

ok, i couldnt find a way to solve this really annoying issue, so i had to hack it a bit. imageviews works perfectly with rotation. so i basically do all the manipulations with image view - and setting it's image out of the emoji text i want using this method:

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;
}

and then i call

    Bitmap bitmap = generateBitmapFromText(stickersStartingSize, res);
    imageview.setImageBitmap(bitmap);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!