Home » Android » android – How to display a text vertically or rotate a TextView in layout XML file?

android – How to display a text vertically or rotate a TextView in layout XML file?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I want to display a string vertically in a view as below, is there have a way to implement that in layout XML file?

enter image description here

How to&Answers:

To rotate the textview in xml use : android:rotation=”-90″

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    android:rotation="-90"/>

Example image

Answer:

add attributes in Text view android:rotation=”-90″

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:rotation="-90"
    android:text="Hello World!" />