Android - Scrolling TextView

I want to scroll the TextView automatically, but I did not succeed (like a tent in html ). Could you tell me how?

Regards

+3
source share
2 answers

A TextView with an ellipse set to a "tent" will not scroll if it has no focus.

Are you looking for a scroll tent regardless of focus?

If so, you can use TranslateAnimation with the LinearInterpolator to give it a constant scroll view. This is what I use and it works great.

    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);
+5
source

You need to look at the property ellipsizein TextView and set it to "marquee". Here's the documentation for Android .

+1
source

Source: https://habr.com/ru/post/1783944/


All Articles