Android 如何旋转文本视图?

Android 如何旋转文本视图?,android,Android,我想旋转TextView,但无法获得正确的输出。我得到了textView,但缺少一些文本 在布局中 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:lay

我想旋转TextView,但无法获得正确的输出。我得到了
textView
,但缺少一些文本

在布局中

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_marginTop = "50dip">

<TextView android:layout_width="wrap_content" android:gravity="bottom"
    android:layout_height="wrap_content" android:id="@+id/text"
    android:text="Shreeji \n Nath" />

</RelativeLayout> 

将main.xml更改为:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <TextView android:layout_alignParentLeft="true"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="TextView" android:layout_marginTop="50dip"
        android:layout_marginLeft="50dip" android:id="@+id/text1"></TextView>

</RelativeLayout>

添加到API 12级

view.animate().rotationBy(90).start()

缺少一些文本?如果在第一个配置中-这意味着您的文本长度超过20dip,如果问题是在旋转过程中,则您设置的文本长度超过20dip,这是因为您的布局太小,无法显示20dipx120dip如果我设置了wrap_内容,则问题仍然存在,但您的问题是在旋转过程中?是的,完全正常(没有旋转,没有问题)奇怪。您的代码正常工作,没有文本丢失。我能看到的唯一问题是你们的动画:持续时间是0,所以实际上你们看不到动画。如果你想检查整个代码,请提供它。是的,我同意Mohit Verma,你的动画可以工作,但你看不到你的文本,因为它是隐藏的。更改页边距,您将看到整个文本。第二个问题是我前面提到的-您的动画正在工作,但您无法看到效果,因为持续时间为0,将其更改为至少1000,您将看到效果。还有一个建议——在android工具中,您有一个名为hierarchyviewer的工具。你可以检查很多关于UI的东西——它非常有用,在这种情况下会帮助你解决问题。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <TextView android:layout_alignParentLeft="true"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="TextView" android:layout_marginTop="50dip"
        android:layout_marginLeft="50dip" android:id="@+id/text1"></TextView>

</RelativeLayout>
view.animate().rotationBy(90).start()