如何在Android中获得具有水平滚动和自动滚动功能的TextView?

发布于 2024-09-04 09:39:31 字数 91 浏览 6 评论 0原文

我想要一个具有水平滚动功能的简单 TextView,我知道我使用 Horizo​​ntalScrollview 来实现这一点,并且我希望文本能够连续自动滚动。这可能吗?

I want to have a simple TextView with horizontal scrolling, I know that I use HorizontalScrollview for that and I want the text to be autoscrolled continuously. Is that possible?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱情眠于流年 2024-09-11 09:39:31

您可以在 TextView 属性中使用 android:ellipsize="marquee" 或实现您自己的动画

You could use android:ellipsize="marquee" in the TextView attributes or by implement your own animation

高冷爸爸 2024-09-11 09:39:31

这是一个简单使用 XML 的自动滚动文本视图的小示例,无需编写 Java 代码。希望你会喜欢它!自己尝试一下,很容易执行

试试这个:

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="This is small example for auto scroll text view simply using XML, no need to code Java. Hope you like it! Try it on your own, it is very easy to perform" />

单击此处查看输出

这里的文本将自动滚动,您将获得无限滚动。玩得开心!

点击此处查看详细教程

This is small example for auto scroll text view simply using XML, no need to code Java. Hope you will like it! Try it on your own, it is very easy to perform

Try this :

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="This is small example for auto scroll text view simply using XML, no need to code Java. Hope you like it! Try it on your own, it is very easy to perform" />

Click here to see the Output

Here text will scroll automatically and you will get infinite scroll. Have fun!

Click here to see detailed tutorial

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文