Android开发TextView内容从右到左滚动

77 阅读1分钟
Android开发TextView内容从右到左滚动

这个功能比较简单,TextView内容从右到左滚动

一、思路:

用TextView的marqueeRepeatLimit

二、效果图:

在这里插入图片描述

三、关键代码:
<com.cong.myrighttolefttextdemo.MarqueeTextView
            android:id="@+id/tv_title"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dp"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:marqueeRepeatLimit="marquee_forever"
            android:singleLine="true"
            android:textColor="@color/white"
            android:textSize="14sp"
            android:text="用户创造的好音乐"/>
四、项目demo源码结构图

在这里插入图片描述
有问题或者需要完整源码的私信我