Android 旋转 TextView 中的错误?

发布于 2024-11-19 00:07:30 字数 686 浏览 1 评论 0原文

像这样定义一个 TextView 元素:

<TextView
    android:id="@+id/rotate_text"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentBottom="true"
    android:text="This text string will behave strangely" 
    android:textSize="14sp"/>

然后对其进行以下旋转并观察会发生什么:

RotateAnimation rot90 = new RotateAnimation(0.0f, -90.0f);
rot90.setDuration(10000);
rot90.setFillAfter(true);
findViewById(R.id.rotate_text).setAnimation(rot90);

随着文本旋转,它会扩展、收缩,有时会在末尾丢失一两个字符。对于给定的角度(0 度或 90 度除外),您将不知道文本最终会持续多长,或者即使会显示全部文本。

应该是这样吗?有解决方法吗?

Define a TextView element like this:

<TextView
    android:id="@+id/rotate_text"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentBottom="true"
    android:text="This text string will behave strangely" 
    android:textSize="14sp"/>

Then give it the following rotation and observe what happens:

RotateAnimation rot90 = new RotateAnimation(0.0f, -90.0f);
rot90.setDuration(10000);
rot90.setFillAfter(true);
findViewById(R.id.rotate_text).setAnimation(rot90);

As the text rotates, it expands, contracts and sometimes loses one or two characters at the end. For a given angle, except 0 or 90 degrees, you won't know how long the text will end up, or even if all of it will be displayed.

Is it supposed to be this way? And is there a workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文