I have a graph and I want to show the name of the axis vertically. But how do I write it vertically along the y-axis ? Tried using textview.setRotation(270)
but had problems with its width as the width was not getting decreased when it was in vertical.
Asked
Active
Viewed 163 times
0

Sparkplug
- 485
- 7
- 21
-
possible duplicate of [Is it possible to write vertically in a textview in android?](http://stackoverflow.com/questions/2888780/is-it-possible-to-write-vertically-in-a-textview-in-android) and [android text view text in vertical direction](http://stackoverflow.com/questions/8604932/android-text-view-text-in-vertical-direction) and [How can we set Vertical TextView?](http://stackoverflow.com/questions/6773693/how-can-we-set-vertical-textview) – Shobhit Puri Sep 04 '13 at 08:07
-
2The simplest thing to do is to add the "\n" (newline) character after each character taken from the `TextView`. There are other methods, but this one is the simplest. You might also want to consider setting it to be multiline too. – g00dy Sep 04 '13 at 08:09
1 Answers
0
One thing you could do is to subclass TextView
and override its onDraw
method
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.translate(0, getHeight());
canvas.rotate(-90);
Layout layout = getLayout();
if (layout != null)
layout.draw(canvas);
canvas.restore();
}

Blackbelt
- 156,034
- 29
- 297
- 305