Android的 - TextView的滚动 [英] Android - TextView scrolling

查看:120
本文介绍了Android的 - TextView的滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想作一个TextView自动滚动,但我没有成功 (如选取框 HTML )。你能告诉我怎么样?

I would like to make a TextView scrolling automatically but I did not succeed (as marquee in html). Could you tell me how?

最好的方面

推荐答案

一个TextView,与ellipsize设置为金字招牌,不会滚动,除非它具有焦点。

A TextView, with ellipsize set to "marquee", will not scroll unless it has the focus.

您是否正在寻找一个选取框不管焦点卷轴?

Are you looking for a marquee the scrolls regardless of the focus?

如果是这样,你可以使用一个TranslateAnimation与LinearInterpolator给它提供一致的滚动的样子。这是我使用并能正常工作。

If so, you could use a TranslateAnimation with a LinearInterpolator to give it that consistent scrolling look. This is what I use and it works fine.

    DisplayMetrics dm = getResources().getDisplayMetrics();

    TranslateAnimation m_ta = new TranslateAnimation(dm.widthPixels, -1 * (dm.widthPixels), 0f, 0f);
    m_ta.setDuration(10000);
    m_ta.setInterpolator(new LinearInterpolator());
    m_ta.setRepeatCount(Animation.INFINITE);

    TextView m_tv = (TextView)findViewById(R.id.tvMarquee);
    m_tv.startAnimation(m_ta);

这篇关于Android的 - TextView的滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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