如何在布局XML文件中垂直显示文本或旋转TextView?

8
我想在视图中垂直显示一个字符串,有没有一种方法可以在布局XML文件中实现?

enter image description here


1
https://dev59.com/gnE85IYBdhLWcg3wNgvk - kgandroid
https://dev59.com/DnM_5IYBdhLWcg3wt1rD#7855852 - Aman Grover
玩一下这个棘手的代码吧... yourTextView.setRotation(-90); - brahmy adigopula
2个回答

17

要在xml中旋转TextView,请使用: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"/>

例子图片


1
在Text View中添加属性android:rotation="-90"。

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接