How to create a vertical TextView (rotated by 90° or -90°) with ellipsize support (meaning that the text is truncated if there is not enough room in the view, and "..." as appended to indicate the truncation), that can be sized with dp
-values, wrap_content
and match_parent
?
All other TextView Options should be honored as well.
It should also not need any extra code to execute rotations or else, and should display correctly in the UI-Editor.
This solution works great, however, overriding onDraw()
results in ellipsize and other features not working anymore. The text will simply disappear if it is too big to display, or other odd things will happen.
The following does the rotation ok, but the ellipsize is calculated based on the width of the view, it should be based on the height if turned 90°.
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.rotate(90, 0, getPaint().getTextSize() +5);
super.onDraw(canvas);
canvas.restore();
}
android:rotation
on the TextView is no good solution, as positioning and sizing does not work properly.
As an option, the View should allow for the text being rotated any angle.