you want to display the vertical text in the picture
used this option to implement vertical textview
http://developer.alexanderklimov.ru/android/views/verticaltextview.php
public class VerticalTextView extends TextView { final boolean topDown; public VerticalTextView(Context context, AttributeSet attrs) { super(context, attrs); final int gravity = getGravity(); if (Gravity.isVertical(gravity) && (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; } else { topDown = true; } } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(heightMeasureSpec, widthMeasureSpec); setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth()); } @Override protected void onDraw(Canvas canvas) { TextPaint textPaint = getPaint(); textPaint.setColor(getCurrentTextColor()); textPaint.drawableState = getDrawableState(); canvas.save(); if (topDown) { canvas.translate(getWidth(), 0); canvas.rotate(90); } else { canvas.translate(0, getHeight()); canvas.rotate(-90); } canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop()); getLayout().draw(canvas); canvas.restore(); } } Faced a problem:
if TextView has a background color, the text is displayed on a colored rectangle.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <test.VerticalTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom|right" android:text="Hello" android:background="#00FF00" /> </LinearLayout> But if you set an image as a background, then it is deformed, getting a width equal to the length of the inscription. How to fix it?
PS The original image for the background has the same width as the green stripe in the first picture
added:
in the proposed version of the vertical TextView, the output area becomes square, and since for the bitmap property gravity = fill, the background is deformed
question: how to trim the width of the output area to the height of the font, so that the area was not square, but rectangular as in this image?
Is it possible to override the methods of the parent class, so that the width and height of the TextView are equal to the original background image?

