[ACCEPTED]-How to Draw TextView on Canvas in android..?-android
Accepted answer
You can't draw a Textview directly, but 2 you can put it in a layout and draw the 1 layout. Something like this:
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);
May be you need to use StaticLayout
. It can draw formatted 2 text, manages word wrapping and so on. Have 1 a look at http://developer.android.com/reference/android/text/StaticLayout.html
You need to create a class which will extend 3 Textview. After that override onDraw method. This 2 method provides you to draw your textview 1 tha way you like it
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.