如何在 android.. 的 Canvas 上绘制 TextView?
我们有 Canvas.DrawBitmap()
、Canvas.drawText()
。 Canvas 中是否有任何将 TextView 作为参数的方法或任何其他方法在 Canvas 上显示 TextView?
实际上,我在 TextView 中有一个字母表,我必须在 Canvas 中的那个字母表上进行绘图。
请提出任何建议....感谢您的合作
最佳答案
Textview 不能直接画,但是可以放在一个布局中,然后 Canvas 局。像这样的:
LinearLayout layout = new LinearLayout(context);
TextView textView = new TextView(context);
textView.setVisibility(View.VISIBLE);
textView.setText("Hello world");
layout.addView(textView);
layout.measure(canvas.getWidth(), canvas.getHeight());
layout.layout(0, 0, canvas.getWidth(), canvas.getHeight());
// To place the text view somewhere specific:
//canvas.translate(0, 0);
layout.draw(canvas);
关于android - 如何在 android.. 的 Canvas 上绘制 TextView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5242757/