如何为textview(非常长的文本)设置动画水平滚动 [英] How to animate the textview (very very long text )scroll automatically horizontally
问题描述
我对选取框不感兴趣,因为在选取框中您无法控制选取框的速度. 我曾尝试为textview设置动画,但是即使所有包含textview的父布局和视图组都设置了两个标志clipchildren = false,clipToPadding = false,父视图也会在最后剪切文本.
I am not interested in Marquee because, in Marquee you can not control the speed of marquee. I have tried to animate the textview but Parent view clips the text at the end even though all parent layout and view groups encompassing textviews are set with two flags clipchildren= false, clipToPadding=false.
我丢失了什么东西吗?还是有更好的解决方法?
Am I missing something or is there a better work around ?
xml看起来像
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="66dp"
android:maxLines="1"
android:singleLine="true"
android:textColor="#585858"
android:textSize="32sp" >
</TextView>
和代码段类似
TextView textView2 = (TextView)findViewById( R.id.textview1 );
textView2.startAnimation((Animation)AnimationUtils.loadAnimation(this, R.anim.translate));
推荐答案
我认为您可以使用翻译动画.像这样
I think you can use translate animation. Something like this
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromXDelta="100"
android:interpolator="@android:anim/linear_interpolator"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toXDelta="-100" />
像这样添加到您的文本视图中
And add to your textview like this
textview.startAnimation((Animation)AnimationUtils.loadAnimation(Context,R.anim.scroll_animation));
希望它可以为您提供帮助.
Hope it can help you.
这篇关于如何为textview(非常长的文本)设置动画水平滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!