当一个TextView的字幕动画已经完成了可检测? [英] Possible to detect when a TextView's marquee animation has completed?

查看:519
本文介绍了当一个TextView的字幕动画已经完成了可检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我一个TextView的 ellipsize 值设置为金字招牌 marqueeRepeatLimit 1为例(以滚动跨越一个TextView一次长文本),有没有什么办法来检测时,字幕动画已完成?

(事情是,我有被添加到动态字符串的队列,我想拉出来,并显示这些字符串,每次一个,一个字符串的长度可以超过TextView的宽度,所以我想滚跨越之前,我展示了下一个。)


  

编辑:如果这是不可能通过的TextView的字幕属性要做到这一点,任何人都知道我可以添加动画到模拟字幕动画一个TextView



解决方案

据我所知,这是不可能的,当一个字幕动画完成,即使我用在TextView的一个翻译的动画复制的字幕动画进行检测,它不会直接地设置动画根据在TextView的文本中的时间长短合适的持续时间。所以!我现在正在做的,而不是按如下方式使用TextSwitcher ...

 < TextSwitcher
    机器人:ID =@ + ID / myTextSwitcher
    ...
    机器人:inAnimation =@动画/ fade_in_slow
    机器人:outAnimation =@动画/ fade_out_slow>
<的TextView
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:单线=真
    机器人:ellipsize =金字招牌
    机器人:marqueeRepeatLimit =marquee_forever
    机器人:可聚焦=真
    机器人:focusableInTouchMode =真/>
<的TextView
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:单线=真
    机器人:ellipsize =金字招牌
    机器人:marqueeRepeatLimit =marquee_forever
    机器人:可聚焦=真
    机器人:focusableInTouchMode =真/>

...并调用 myTextSwitcher.setText(旁边的文字说明)方法,每隔一段时间使用定时器。不理想,但最好我能想出!

If I set a TextView's ellipsize value to "marquee" and the marqueeRepeatLimit value to "1" for example (in order to roll a long text across a TextView once), is there any way to detect when the marquee animation has completed?

(Thing is, I have a queue of Strings which is being added to dynamically and I want to pull out and show one of these Strings at a time. A String can be longer than the width of the TextView so I want to roll it across before I show the next one.)

Edit: If it's not possible to do this by using TextView's marquee properties, anyone know how can I add an Animation to a TextView which simulates a marquee animation?

解决方案

As far as I can tell, it's not possible to detect when a marquee animation completes and even if I replicated the marquee animation using a translate animation on the TextView, it wouldn't be straightforward to set the duration of the animation the right length of time according to the text in the TextView. So! What I'm doing now instead is using a TextSwitcher as follows...

<TextSwitcher
    android:id="@+id/myTextSwitcher"
    ...
    android:inAnimation="@anim/fade_in_slow"
    android:outAnimation="@anim/fade_out_slow" >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:focusable="true"
    android:focusableInTouchMode="true" />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:focusable="true"
    android:focusableInTouchMode="true" />

... and calling the myTextSwitcher.setText("text to show next") method every so often using a Timer. Not ideal but the best I could come up with!

这篇关于当一个TextView的字幕动画已经完成了可检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆