如何使谷歌播放像文本视图动画时文本太长



在Google Play中,当某个标题的名称太长时,他们会在此TextView上应用动画,当名称从TextView的一端出去,从另一端进入,在标题文本的开头停止一秒钟,然后进行下一轮。

有没有人解释如何实现这一目标?

这对我有用,您必须实际请求焦点才能使选框动画正常工作:

  <TextView
        android:id="@+id/tvAddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/tvName"
        android:layout_toLeftOf="@+id/ivLogo"
        android:text=""
        android:textColor="@color/cups_white"
        android:textSize="18sp" 
        android:ellipsize="marquee"
        android:singleLine="true"
        android:marqueeRepeatLimit ="marquee_forever"
        android:scrollHorizontally="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:duplicateParentState="true">
        <requestFocus 
          android:focusable="true" 
          android:focusableInTouchMode="true"
          android:duplicateParentState="true" />
    </TextView>

在声明文本视图的 xml 文件中,可以使用以下属性:

android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"

使用单行,您将确保文本仅在一行中显示结束。

有关更多详细信息,请查看以下内容:http://developer.android.com/reference/android/widget/TextView.html

最新更新