有没有一种方法,使ellipsize ="字幕"一直滚动? [英] Is there a way to make ellipsize="marquee" always scroll?

查看:217
本文介绍了有没有一种方法,使ellipsize ="字幕"一直滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用一个TextView字幕效果,但是当TextView中获得焦点的文本只被滚动。这是一个问题,因为在我的情况,它不能。

I want to use the marquee effect on a TextView, but the text is only being scrolled when the TextView gets focus. That's a problem, because in my case, it can't.

我使用的:

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

有没有办法有TextView的总是滚动的文字?我已经看到了这个正在做在Android Market的应用程序,其中应用程序名称将滚动的标题栏,即使它不接收焦点,但我无法找到这个被提到的API文档。

Is there a way to have the TextView always scroll its text? I've seen this being done in the Android Market app, where the app name will scroll in the title bar, even if it doesn't receive focus, but I couldn't find this being mentioned in the API docs.

推荐答案

我一直面临的问题,我已经提出了用最短的解决方案是创建一个从TextView中派生新类。 该类应覆盖三个方法 onFocusChanged onWindowFocusChanged isFocused ,以使TextView的全部集中。

I have been facing the problem and the shortest solution I have come up with is to create a new class derived from TextView. The class should override three methods onFocusChanged, onWindowFocusChanged and isFocused to make the TextView all focused.

@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
    if(focused)
        super.onFocusChanged(focused, direction, previouslyFocusedRect);
}

@Override
public void onWindowFocusChanged(boolean focused) {
    if(focused)
        super.onWindowFocusChanged(focused);
}


@Override
public boolean isFocused() {
    return true;
}

这篇关于有没有一种方法,使ellipsize ="字幕"一直滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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