本篇文章为大家展示了如何在Android中利用TextView实现一个跑马灯效果,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。Android自带的跑马灯效果不太好控制,还必须要满足条件才能有效果,而
本篇文章为大家展示了如何在Android中利用TextView实现一个跑马灯效果,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
Android自带的跑马灯效果不太好控制,还必须要满足条件才能有效果,而且速度不受控制。前面我的博客中有一篇就是用Android自带的跑马灯效果的,但是基于不同的使用效果,这里在网上找到了一个更好的方法。沿用了作者的一些方法,但是添加了更好的扩展功能,和大家一起分享。这里面有控制往左往右两个方向的实现。
首先是简单的布局main.xml
<LinearLayout xmlns:android="Http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/start" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="start" android:text="开始" /> <Button android:id="@+id/stop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="stop" android:text="停止" /> <Button android:id="@+id/startfor0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="startFromHead" android:text="重置" /> <com.xuhui.customrolllight.MarqueeText android:id="@+id/test" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#339320" android:ellipsize="marquee" android:singleLine="true" android:text="滚动效果,不管多少字" android:ellipsize = "marquee" // 跑马灯效果,字数不超过就不动,超过就滚动 android:textColor="#000000" android:textSize="20dp" > </com.xuhui.customrolllight.MarqueeText> </LinearLayout>
--结束END--
本文标题: 如何在Android中利用TextView实现一个跑马灯效果
本文链接: https://www.lsjlt.com/news/223123.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0