Good day. I would like to know a rational way of vertical text display. It was possible to google the variant with drawing on the canvas and using the rotation animation.

    2 answers 2

    I was also here once advised to do so. But I solved this question differently:

    TextView textView = new TextView(activity) { @Override protected void onMeasure(int widthSpec, int heightSpec) { super.onMeasure(heightSpec, widthSpec); setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth()); } @Override protected boolean setFrame(int left, int top, int right, int bottom) { super.setFrame(left, top, left + (bottom - top), top + (right - left)); } @Override public void draw(Canvas canvas) { canvas.translate(0, getWidth()); canvas.rotate(-90); canvas.clipRect(0, 0, getWidth(), getHeight(), Op.REPLACE); super.draw(canvas); } }; 
    • Thanks, I just had to perform the rotation in one application, so that the bounding box also rotated. And with standard animation, only the view view rotates and the clickable area remains the same - LackOfKnowledge

    In principle, the same as above, but here is a ready class:

     public class VerticalTextView extends android.support.v7.widget.AppCompatTextView{ public VerticalTextView(Context context) { super(context); } @Override protected void onMeasure(int widthSpec, int heightSpec) { super.onMeasure(heightSpec, widthSpec); setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth()); } @Override protected boolean setFrame(int left, int top, int right, int bottom) { super.setFrame(left, top, left + (bottom - top), top + (right - left)); return true; } @Override public void draw(Canvas canvas) { canvas.translate(0, getWidth()); canvas.rotate(-90); canvas.clipRect(0, 0, getWidth(), getHeight(), Region.Op.REPLACE); super.draw(canvas); } 

    }