Android TextView设置跑马灯效果不生效-解决

TextView跑马灯效果不生效

  • 解决方案一
<TextView
                android:id="@+id/music_name_tv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ellipsize="marquee"   【必须】
                android:focusable="true"      【必须】
                android:focusableInTouchMode="true" 【必须】
                android:lines="1"              【必须】
                android:text=""
                android:textColor="@color/colorAccent"
                android:textSize="15sp" />
  • 解决方案二(生效)
public static void setTextMarquee(TextView textView) {
        if (textView != null) {
            textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            textView.setSingleLine(true);
            textView.setSelected(true);
            textView.setFocusable(true);
            textView.setFocusableInTouchMode(true);
        }
    }
发布了175 篇原创文章 · 获赞 56 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_39424143/article/details/104372756